有没有办法获取本地虚拟机上运行的进程列表?
我有一个在 Windows 7 上运行的虚拟机,名为“VirtualXP-12345”。我尝试
System.Diagnostics.Process.GetProcesses("VirtualXP-12345")
从主机使用,但这不起作用。我刚刚得到 InvalidOperationException(“无法连接到远程计算机。”)。
我正在尝试编写一个程序来检查 PC 上是否正在运行特定进程,包括也在该计算机上运行的所有虚拟机。在本地非虚拟机上使用 Pocess.GetProcesses() 可以正常工作,但我需要确定该进程是否在本地计算机上的任何位置运行,因为需要关闭它才能更新正在使用的文件。
I've got a virtual machine running on Windows 7 called "VirtualXP-12345". I tried using
System.Diagnostics.Process.GetProcesses("VirtualXP-12345")
from the host machine but that doesn't work. I just get InvalidOperationException("Couldn't connect to remote machine.").
I am trying to write a program that checks that a particular process is running on a PC, including all virtual machines also running on that machine. It works fine using Pocess.GetProcesses() on the local non-virtual machine, but I need to determine if the process is running anywhere on the local machine, as it needs to be shut down in order to update files in use.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
默认情况下,您无法连接到 Windows 7 计算机并获取进程列表。尝试关闭虚拟机中的固件,看看是否有帮助。
By default you can't connect to a windows 7 machine and get a list of processes. Try turning off the firware in your VM and see if that helps.
根据文档,您正在使用正确的 API 调用来获取另一台计算机上的进程(虚拟与否并不重要)。
您返回的错误表明这是连接问题。要解决这个问题,您应该首先检查:
\\virtualxp-12345
)According to the documentation, you are using the right API call for getting process on another machine (virtual or not doesn't matter).
The error you get back specifies that it is a connectivity issue. To fix that, you should start by checking that:
\\virtualxp-12345
)不太确定,但我认为你不能,因为基本上,虚拟机就像局域网中的另一台机器。您需要“有人与您合作”。换句话说,您可以通过网络调用一些工具并检索进程列表。
事实上,在设置计算机期间,您设置了 Bridge/NAT/... 网络类型(如果您还记得的话),就像您想设置 LAN 一样。
问候。
Not really sure, but I think you can not, as basically, virtual machnie is like another machine in your LAN. You need that "someone collaborates" with you on its side. In other words some tool, that you can call via network and retrive process list.
Infact during the setup of your machine you set Bridge/NAT/... network type, if you remember, just like if you would like to setup LAN.
Regards.