从 java 运行 PSExec 不起作用
我想在不同的用户下从我的 java 服务器运行 CSharp 进程。 我使用 PSExec 来执行此操作 - 它在我的 PC 上运行良好,但在“真实”服务器上执行此操作时,进程立即崩溃。 (似乎 CSharp 应用程序甚至没有启动 - 我尝试将某些内容作为第一个命令打印到文件中,但没有写入任何内容)。
运行java进程的用户和其他用户都属于管理员组。
我不知道为什么应用程序崩溃。
这是我的代码:
ProcessBuilder processBuilder = new ProcessBuilder(
"c:\\pstools\\PsExec.exe",
"-u",
"username",
"-p",
"password",
appPath,
arg1,
arg2);
processBuilder.start();
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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用 Zoltan Csizmadia 的 XCmd :
http://feldkir.ch/xcmd.htm
这个问题已在 sysinternals 论坛上讨论过,我记得psexec 使用的 EOL 符号有问题。
使用 xcmd 不会有任何问题
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
我的病毒扫描程序不允许 xcmd。
然而 paexec 是 psexec 的直接替代品,也可以完美运行。
http://www.poweradmin.com/PAExec/
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/
它工作得很好。请记住,您的 ShellCommandString 中需要有两个 \\。
我的同事刚刚向我提出了这个问题,我用谷歌搜索并找到了这个页面。
processBuilder 会工作得很好,确保你拥有的 Stirng = 你希望在 cmd 中拥有的 Stirng
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