Click here to Skip to main content
15,889,826 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
Hello.

 I have a batch file named a.bat on a winserver2008 Desktop.
That batch file only write the SessionID (from environment variable) to a local eventlog.

I want to execute it remotely using cmd (otherwise the SessionName doesn't appear).
so I have tried
<code>c:\PsTools\psexec.exe \\<Server> -u test2 -p <Password> -i 2 cmd "c:\Users\test-2\Desktop\a"</code>
or

<code>c:\PsTools\psexec.exe \\<server> -u test2 -p <Password> -i 2 "cmd \"c:\Users\test-2\Desktop\a\"";exit</code>

all of these just open a terminal on the remote machine but don't execute the batch.
Any ides?

Best Regards,
Posted

1 solution

Try this:
psexec.exe \\<Server> -u test2 -p <Password> -d -i "c:\Users\test-2\Desktop\a.bat"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900