2

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.

Mark Lakata
  • 19,989
  • 5
  • 106
  • 123
  • 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. – Tigran Jul 11 '11 at 19:31

3 Answers3

1

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.

Peter Ritchie
  • 35,463
  • 9
  • 80
  • 98
1

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:

  • Your host machine can map the name to an IP address (test with ping).
  • You have basic IP connectivity (test with ping).
  • Your virtual machine allows inbound connections on port 445, which is RPC over TCP/IP that is used by all Windows core networking features. (Simple test is to hit start->run and type \\virtualxp-12345)
Anders Abel
  • 67,989
  • 17
  • 150
  • 217
  • I disabled the firewall, and that let me ping. I tried testing port 445 by going to "\\VirtualXP-12345" and it prompted me for a password. I tried – Mark Lakata Jul 13 '11 at 18:35
  • sorry, my machine crashed while typing! I tried using the VirtualXP-12345\XPMUser login and the correct password, but that would not let me log in to the VM successfully. – Mark Lakata Jul 13 '11 at 18:50
  • Do your `XPMUser` have sufficient rights to view the VM over the network? To have your program allowed to view the processes of the VM you first need to authenticate successfully to the VM. The `net use` command on the commandline can be used to established an authenticated connection that other programs can use. – Anders Abel Jul 14 '11 at 20:00
0

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.

Tigran
  • 61,654
  • 8
  • 86
  • 123