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
Related videos on Youtube
Author by
Alex
Updated on September 18, 2022Comments
-
Alex almost 2 years
I have two Windows computers
A
andB
, and I want to remotely run a command on computerB
. I use the toolpsexec
, so on computerA
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 over 9 yearsI see. Perfect, just what I was missing here. Thanks.