I am experimenting with PsExec and I am trying to run a batch file on a remote host from a local PC on the same LAN. The batch file has been tested on the local PC and works fine. I managed to connect to the remote host via PsExec using the below commands.
PsExec -u Username -p Password \\Remote_Host_IP C:\Path_to_batch_file\Batch.bat
I am getting this error:-
PsExec could not start C:\Path_to_batch_file\Batch.bat on Remote_Host_IP: The system cannot find the file specified.
This is probably occurring since it is searching for the file on the remote host while the file is located on the local PC thus not finding the file. I do not want to make any manual intervention on the remote host.
After trying hard to find the correct commands on the net I cannot solve this issue.
PsExec -u Username -p Password \\Remote_Host_IP \\%computername%\C$\Path_to_batch_file\Batch.bat
The computername variable will be evaluated on your local machine but the remote user has to have the rights to read the file on your local machine. (In this case the admin share). In any other case you have to copy the file to the remote host (or embed it in the PsExec statement) – Clijsters