Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

355
Views
How can I respond to a prompt in Node.JS child process

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");

Here's the response: Image of the response

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

RUNAS directly prevents people from using it insecurely, however I can include this file with my package and use it instead: https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

Example; psexec.exe -u Manxy -p "ThisIsThePassword" cmd.exe

This greatly simplifies it for me.

Thank you, jsejcksn for the link

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!