I'm trying to write a program that runs a series of commands as my other user account, which is an administrator, however I'm running into an issue where the "Please enter the password" part of this is completely skipped, filled in with random blank spaces for no reason.
How do I go about responding to prompts in Node.JS child procsses?
Here's my code:
var {spawn} = require("child_process");
var cmd = spawn("cmd.exe");
var sleep = t => new Promise(r => setTimeout(r, t * 1000));
cmd.on('close', code => interact({message: "Command executed."}));
// "interact" is a pop-up function, it'll be removed when testing is done, it functions as expected no issues.
cmd.stdout.on('data', text => console.log(Buffer.from(text).toString()));
cmd.stderr.on('data', text => console.log('Err:', Buffer.from(text).toString()));
cmd.stdin.write("runas /profile /user:Manxy \"cmd.exe\"\n");
await sleep(.2);
cmd.stdin.write("ThisIsThePassword\n");
await sleep(.2);
cmd.stdin.write("exit\n");