How can I run a windows batch internal command remotely?

1

I have two Windows computers A and B, and I want to remotely run a command on computer B. I use the tool psexec, so on computer A I can run:

psexec.exe \\10.0.0.2 -u user -p pasword c:\programs\whatever\commando.exe

to execute the command on computer B. So fine so good.

But how to simply run dir on the remote computer, which is an internal batch command?

 psexec.exe \\10.0.0.2 -u user -p pasword dir

just gives

The system cannot find the file specified.

Alex

Posted 2014-11-21T15:16:21.507

Reputation: 337

Answers

5

Try this example:

psexec \\10.0.0.2 -u user -p pasword -s cmd /c dir c:\

The key is the cmd /c to access the cmd shell

Source: http://ss64.com/nt/psexec.html

Kinnectus

Posted 2014-11-21T15:16:21.507

Reputation: 9 411

I see. Perfect, just what I was missing here. Thanks. – Alex – 2014-11-21T15:34:00.270