我怎样才能获得WMI的退出代码纺远程进程 [英] How can I get an exit code from WMI spun remote process
本文介绍了我怎样才能获得WMI的退出代码纺远程进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在远程执行过程通过WMI(Win32_Process的创建),但我无法弄清楚我怎么能确定何时过程已完成执行。当我第一次发出命令,有一个退出代码(0表示成功),但只是告诉我,这个过程已经成功地产生了。
I'm executing a process remotely via WMI (Win32_Process Create) but am unable to figure out how I can determine when the process has completed executing. When I first issue the command, there is an exit code (0 for success) but that just tells me the process has been successfully spawned.
有没有一种方法,当过程结束我能知道吗? !谢谢
Is there a way I can know when the process ends? Thanks!
推荐答案
面对同样的问题,写了一个简单VMI包装:
Faced same issue and wrote a simple VMI wrapper:
var exitStatus = WmiOperations.Run("notepad.exe", wait:10);
简介为运行
是:
int Run(string command, // Required
string commandline = null, // (default=none)
string machine = null, // (default=local)
string domain = null, // (default=current user domain)
string username = null, // (default=current user login)
string password = null, // (default=current user password)
SecureString securePassword = null, // (default=current user password)
double wait = double.PositiveInfinity); // (default=wait til command ends);
源代码可以从的这里
的给凯撒他应有的,代码从的这个。简单地说:的
Give caesar his due, code is inspired from this one. Simply:
- 的重构事情静态类的
- 的增加了更多的控制上远程处理参数的
- 的重新设计的事件观察打压吸引力
CheckProcess
测试的
- Refactored things to static class
- Added more control on remoting parameters
- Redesigned event watcher to suppress the unappealing
CheckProcess
test
这篇关于我怎样才能获得WMI的退出代码纺远程进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文