WMI和获取VB.net中运行进程的CommandLine
这是我想在 VB.NET 程序中使用的命令行。查找正在运行的进程“mpc-hc.exe”并获取正在运行的进程的命令行
wmic process where name='mpc-hc.exe' get CommandLine
我想将该命令的输出检索到字符串中。我知道它可以在 VB.NET 程序中本地完成,并且我已经研究了它是如何完成的。但是,我无法让代码执行上面命令行中的操作。
关于我应该如何实施这个有什么建议吗?谢谢。
This is the command line I want to use inside my VB.NET program. Look for the running process "mpc-hc.exe" and get the commandline of the running process
wmic process where name='mpc-hc.exe' get CommandLine
I want to retrieve the output from that command into a string. I know that it could be done natively in a VB.NET program and I have looked at how it was done. However, I cannot get the code to perform what it did in the commandline I have above.
Any suggestions on how should I implement this? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
wmic
是Windows Management Instrumentation (WMI) API 的命令行包装器。在 .NET Framework 中,System.Management
命名空间提供对此 API 的访问。下面是与命令行等效的 Visual Basic .NET。此代码查询
Win32_Process
类实例对应于 mpc-hc.exe 并读取其CommandLine
属性:wmic
is a command-line wrapper for Windows Management Instrumentation (WMI) API. In .NET Framework, theSystem.Management
namespace provides access to this API.The Visual Basic .NET equivalent of your command line is below. This code queries the
Win32_Process
class instances corresponding to mpc-hc.exe and reads theirCommandLine
property: