I have a C# program that automatically test something on a remote computer. I can run it locally from my development machine, but typically it's ran from build agents on our TeamCity server. The command doesn't do anything other than running a dummy file to confirm the machine is up and running:
PsExec.exe \\10.2.1.216 -u TestUser -p *** -h -accepteula -nobanner -c -f -w C:\ dummy.cmd
On my machine it works well:
PsExec.exe \\10.2.1.216 -u TestUser -p *** -h -accepteula -nobanner -c -f -w C:\ dummy.cmd
Connecting to 10.2.1.216...
Starting PSEXESVC service on 10.2.1.216...
Connecting with PsExec service on 10.2.1.216...
Copying dummy.cmd to 10.2.1.216...
Starting dummy.cmd on 10.2.1.216...
dummy.cmd exited on 10.2.1.216 with error code 0.
On the TC server however, it fails with the very vague "handle is invalid" error:
PsExec.exe \\10.2.1.216 -u TestUser -p *** -h -accepteula -nobanner -c -f -w C:\ dummy.cmd
The handle is invalid.
Connecting to 10.2.1.216...
Couldn't access 10.2.1.216:
RunCommand process exited with 6