How can I run a windows batch internal command remotely?

10,886

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

Share:
10,886

Related videos on Youtube

Alex
Author by

Alex

Updated on September 18, 2022

Comments

  • Alex
    Alex almost 2 years

    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
    Alex over 9 years
    I see. Perfect, just what I was missing here. Thanks.