batch-filepsexecremote-connection

Error using PSEXEC to start a file on a remote computer


I have created a small script that initiates PSEXEC to run a file (a registry key) on a remote computer that is in the domain; however, when I run the script I receive an error indicating that "the system cannot find the file specified."

Below is my script:

@echo off
psexec \\PRECDP19425 -u PRECDP19425\WAKE -p <password> -h -i -d C:\Users\WAKE\Documents\AllowNetwork.reg
pause

I have double-checked the location to make sure I wasn't losing my mind and typed something incorrectly, yet that doesn't seem to be the case. The path is correct, I'm just not sure what is causing the script to fail.

The exact error I receive is:

PsExec could not start C:\Users\etc on PRECDP19425

The system cannot find the file specified.

Any help would be much appreciated.


Solution

  • C:\Users\WAKE\Documents\AllowNetwork.reg is not a valid command line because a .reg file is not an executable, you need to pass it to reg.exe:

    REG IMPORT C:\Users\WAKE\Documents\AllowNetwork.reg