Reputation: 24737
I want to run a CSharp process from my java server under a different user. I use PSExec to do this - it works fine on my PC, but when doing it on a "real" server, the process immediately crashes. (It seems that the CSharp app does not even start - i tried to print something to a file as the first command, but nothing was written).
Both the user that run the java process and the other user are in the Administrator group.
I have no idea why the application crashes.
This is my code:
ProcessBuilder processBuilder = new ProcessBuilder(
"c:\\pstools\\PsExec.exe",
"-u",
"username",
"-p",
"password",
appPath,
arg1,
arg2);
processBuilder.start();
Upvotes: 2
Views: 5067
Reputation: 327
It works just fine. Remember that you need to have double \\ in your ShellCommandString. My coworker just came to me with this question, i googoled it and got to this page.. processBuilder will work just fine, make sure the stirng you have is = the stirng you wish to have in cmd
ProcessBuilder processBuilder = new ProcessBuilder(
"Psexec \\\\\\\\10.192.246.76 -i -u Administrator -p admin2193 cmd /c C:\\\\CI\\\\AutoTest\\\\agent_test1.bat");
processBuilder.start();
Upvotes: 0
Reputation: 56332
My virus scanner doesn't allow xcmd.
However paexec is a drop-in replacement for psexec that also works perfectly.
http://www.poweradmin.com/PAExec/
Upvotes: 0
Reputation: 57252
try with XCmd by Zoltan Csizmadia : http://feldkir.ch/xcmd.htm
This problem has been discussed on sysinternals forum and as I remeber there was a problem with EOL symbol that psexec uses.
You'll have no problems with xcmd
Upvotes: 1