Question

I'm trying to launch an exe remotely but I can't get the program to run with the custom flag /r.

psexec -u DOMAIN\Username -p Password -s \\XXX.XXX.XXX.XXX -i "C:\Windows\System32\Program.exe /r"

However the output I get is exited on XXX.XXX.XXX.XXX with error code 87. Which is the error code for an invalid argument.

Was it helpful?

Solution

Turns out the problem was not with the code but the server I was testing on. Shame on me for assuming that Windows would do what it's supposed to. The application had crashed several days ago hence why the cmd was failing. This works perfectly:

psexec -u domain\username -p password -s \\XXX.XXX.XXX.XXX -i "C:\Windows\System32\Program.exe\" /r

Bonus round After running the cmd the server needs to reboot and that was a pain to get working. I kept getting different error codes and then finally had trouble finding a way to give the server a shutdown reason. Here is my code for that. It reboots(/r), forces the shutdown(/f), time delay of 1 second(/t 1), marks the shutdown reason as unplanned reason 00:00(/d U:00:00).

psexec \\XXX.XXX.XXX.XXX -e -u domain\username -p password shutdown /r /f /t 1 /d U:00:00
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top