15

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

0

2 Answers 2

1

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.

0

you need to add credential as well to run that exe.(Pass the credential in PSEXEC command) Make sure that your account also has the write and modify permission at the location at which file is being generated

3
  • the credentials passed in first command are of the remote pc. When I do the same for second command , it says Logon failure unknown username or bad password
    – sukesh
    Sep 2, 2015 at 12:52
  • Just make sure your account has permission to write and modify files at that folder. Sep 2, 2015 at 12:57
  • I modified TestFile.exe. It just opens a notepad now. But even that isn't happening. Does this require rights too. I'm not sure how to check that.
    – sukesh
    Sep 2, 2015 at 13:29

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.