Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda