Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

257
Visualizações
how to execute remote operation to windows machine via nodejs

I finally joined the community

So for my first question in this community:

Generally I want to execute some remote operations to a remote windows machine in node.js (of course I have permissions, credential and so on to the remote machine).

Specifically, right now I'm trying to retrieve list of services from windows machine. I've tried using the wmi-client package in order to do so:

const WmiClient = require('wmi-client');
var wmi = new WmiClient({
    username: '*****',          //credentials - username 
    password: '*****',          //credentials - password
    host: '*********',          // remote windows machine
});

wmi.query(`Select * from Win32_Service`, function (err, result) {
    console.log(result);
});

but I keep receiving error: Exit code: 44125. Invalid Global Switch.

I'll mention that using wmi in powershell make no issues for me. but when I trying to use the same technology in nodejs its failed. what am I doing wrong? Any other suggestions?

just to mention, when I need to retrieve same info from linux machine I easiliy do it using 'simple-ssh' package, without any issues:

    const SSH = require('simple-ssh');
    
    var ssh = new SSH({
      host: '*******',         // remote linux machine
      user: '*******',         // credentials - username
      pass: '*******'          // credentials - password
    });

      ssh.exec(`systemctl list-units --full -all`, {
          out: function(stdout) {
            // stdout as expected
          }
      }).start()});

but things getting complicated when trying to do the same for windows remote machine.

any ideas? Thank you very much!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

seems like the following is working for me:

var exec = require('node-ssh-exec');

var config = {
    host: '*******',
    username: '***',
    password: '***'
},
command = 'sc query';

exec(config, command, function (error, response) {
if (error) {
    throw error;
}

the response is as expected, but for some reason the error associated with it is not empty:

{ errno: -4077, code: "ECONNRESET", syscall: "read", level: "connection-socket", }

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda