1

I'm using require("child_process").spawn and calling an executable, which at the beginning is pausing for a password to be input; if I use it like below:

var spawn = require("child_process").spawn;
var exe = spawn("NameOfExe.exe", [/*arguments*/], {stdio: [process.stdin, process.stdout, process.stderr]});

It works perfectly (Yes, I know I can do inherit, shush :p ). I can type inside my console and it'll accept it with no issues.

However, if I do it like this:

var spawn = require("child_process").spawn;
var exe = spawn("NameOfExe.exe", [/*arguments*/], {stdio: ["pipe", process.stdout, process.stderr]});
exe.stdin.write("Password\n");

then the executable doesn't even receive the stdin; it immediately goes to Execution Failed.

I'm completely at a loss for this. Any suggestions?

EDIT:

I think I may be onto something!

So I'm 99.99% certain that the executable is using C# and Console.ReadKey to get the password. However, according to Microsoft, an exception gets thrown whenever the In property is redirected somewhere else.

So this explains it, but is there a way around this using Node, or am I at the mercy of the people who made this executable?

1 Answer 1

1
The ReadKey method reads from the keyboard even if the standard input is redirected to a file with the SetIn method.

You figured it out. It uses native bindings to the hardware controller/HAL, and not the shell, to handle stdio.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.