There is an exe (D:\TestFile.exe) in remote pc(SYSDES208). When run, it just creates a text file with some text. It works fine when run manually.
I'm trying to execute this from another PC this way, in command prompt.
D:\PsTools>cmdkey.exe /add:SYSDES208 /user:admin /pass:admin123
//Message - CMDKEY: Credential added successfully
D:\PsTools>psexec \\SYSDES208 D:\TestFile.exe
//Message - D:\TestFile.exe exited on SYSDES208 with error code 0.
There is no error and also no text file created.
The credentials passed in the command are of the remote PC's.
UPDATE: Thought of using a batch file instead, to run the exe. So, I created a batch file with this code and placed it in the remote pc (D:\Test.bat):
start /d "D:\" TestFile.exe
Here are the commands run from the local PC:
D:\PsTools>cmdkey.exe /add:SYSDES208 /user:admin /pass:admin123
//Message - CMDKEY: Credential added successfully
D:\PsTools>psexec \\SYSDES208 D:\Test.bat
//Message - c:\windows\system32>start /d "D:\" TestFile.exe
D:\Test.bat exited on SYSDES208 with error code 0
As seen in the message, the batch file is executed but the exe is not. What am i missing here
PsExec allows you to run the command simultaneously on multiple remote computers. To do this, you can set the computer names separated by commas: psexec PC1,PC2 “ipconfig /all” or save them in a text file, and then specify a path to this file: psexec @c:\ps\computer_list. txt ipconfig.
PsExec or psexec.exe is a command-line utility built for Windows. It allows administrators to run programs on local and more commonly remote computers. It is a free utility part of the Sysinternals pstools suite built by Mark Russinovich many years ago.
PsExec is a utility tool that allows system administrators to control a computer from a remote location. It's a command-line interface that requires no software installation like some of the popular remote administrative tools.
Sys admins will say yes because it's a useful tool and part of windows.
My network admins would use Powershell for this. Not sure if you are restricted to only CMD.
invoke-command -computername SYSDES208 -scriptblock { D:\TestFile.exe }
If you are using a domain account or have the exact same account on the remote machine you shouldn't need to enter credentials as powershell will use the cred of the local user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With