is it possible that a vmware guest VM can see/recognize the host OS process ids? Any solutions/workarounds

Hi there;

is it possible that a vmware guest VM can see/recognize the host OS process ids? Any solutions/workarounds?

Both are Windows.

Regards.
LVL 12
jazzIIIloveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ry_berkCommented:
I dont believe that a guest OS can see the hosts processes.

Would this not kind of defeat the purpose of virtualization?
0
jazzIIIloveAuthor Commented:
who knows?
0
coolsport00Commented:
What are you wanting to achieve "jazzIIIlove"?

You can open up Computer Management in Admin Tools, select the Action tab, then 'Connect to another computer' and type the Windows host name . You can from there see it's "services", but you can't see it's processes...like in Task Mgr. There may be a way to do this via CMD Prompt...not sure.

~coolsport00
0
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

jazzIIIloveAuthor Commented:
just get the pid of host and compare the same process with diffeent id in guest with any language; java or C# mainly.
0
Tech_StigCommented:
You could achieve this using a WMI query.

The example found here is a good start. http://www.computerperformance.co.uk/vbscript/wmi_process.htm

Just replace the value of  strComputer with that of your IP or hostname.
0
jazzIIIloveAuthor Commented:
ok, i tried for it, it's working in local machine flawlessly but in vm, it failed:
I can ping the guest vm from host machine but I have an error as:

************** Exception Text **************
System.Exception: Cannot create ActiveX component.
   at Microsoft.VisualBasic.Interaction.GetObject(String PathName, String Class)
   at PIDDetector.Form1.Button1_Click(Object sender, EventArgs e) in C:\VSWorks\PIDDetector\PIDDetector\Form1.vb:line 14
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

What should I do?

Best regards.

        Dim objWMIService, objProcess, colProcess
        Dim strComputer, strList        

        'strComputer = "."
        'strComputer = "vmip"
        strComputer = "vmhostname"    

        objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" _
        & strComputer & "\root\cimv2")

        colProcess = objWMIService.ExecQuery _
        ("Select * from Win32_Process")

        For Each objProcess In colProcess

            strList = strList & vbCr & _
            objProcess.Name
            TextBox1.Text += objProcess.Name & vbNewLine
        Next

Open in new window

0
jazzIIIloveAuthor Commented:
ok, whatever I did in guest vm to have the ip address similar as 192.168.2.x, the program gives the same error, so I tried the program not in a guest OS but another XP machine in the same network, guess what, same error.

What is the problem?

Regards.
0
jazzIIIloveAuthor Commented:
ok, I plugged another machine XP to the network and tried for it. My 7-64 bit is unable to reach it and i convert the above code from vb.net to vbs and i got an error indicating a permission error as:
Code 800A0046 - Permission Denied

I checked for the following link but no avail.
http://www.microsoft.com/downloads/details.aspx?FamilyId=7B9BA261-7A9C-43E7-9117-F673077FFB3C&displaylang=en

Then I run the same code from XP box, this time changing the ip of vbs, and guess what, the vbs worked. So, XP can reach and take the process list of the 7, vice-versa failed.

I am right now, trying to figure out the problem, they are in the same network and the firewalls are closed together with AVs

Another thing is since I am trying this for the guest VM and since the guest VM and running host are not in the same network area, i need to change the guest VM's network stuff compatible with 7's network area as in this question, i asked a couple of minutes ago:

http://www.experts-exchange.com/Software/VMWare/Q_25791864.html

Best regards

0
Tech_StigCommented:
I saw your net config on your other post. Now you are bridging the adapter and you should be able to ping from the XP Host to the 7 Guest AND the 7 Guest to the XP host correct?

If the firewall on either box is on you will have to allow icmp to be able to ping and TCP 135 for WMI.

http://msdn.microsoft.com/en-us/library/aa389286(VS.85).aspx

Also, attached is a sample program console program in c# to grab this info using the System.Management namespace. You'll have to add a reference to System.Management in order for it to compile. It also might throw out some useful exceptions to help in debugging this issue.




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;


namespace GetPidsFromRemoteHost
{
    class Program
    {
        struct MyProcess
        {
            public string name;
            public string PID;
        }
        static void Main(string[] args)
        {
            string hostname = "MyHost";
            List<MyProcess> procs = GetProcesses(hostname);
            foreach (MyProcess p in procs)
            {
                Console.WriteLine(p.name + "\t" + p.PID);
            }
            Console.Read();
        }

        static List<MyProcess> GetProcesses(string hostname)
        {
            ManagementScope scope = new ManagementScope("\\\\" + hostname + "\\root\\cimv2");
            ManagementPath path = new ManagementPath("Win32_Process");
            ObjectGetOptions obj = new ObjectGetOptions(null);
            ManagementClass wmi = new ManagementClass(scope, path, obj);
            List<MyProcess> procs = new List<MyProcess>();

            try
            {
                foreach (ManagementObject mo in wmi.GetInstances())
                {
                    MyProcess mProc = new MyProcess();
                    mProc.name = mo.Properties["Name"].Value.ToString();
                    mProc.PID = mo.Properties["ProcessId"].Value.ToString();
                    procs.Add(mProc);
                }
            }
            catch (ManagementException e)
            {
                Console.WriteLine(e.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return procs;
        }
    }
}

Open in new window

0
jazzIIIloveAuthor Commented:
ok, first of all, thanks for your interest. When I run your code, the following error is what I have got.

It seems all the problem is username password authentication stuff and idiot nature of 7-64 bit. I figure out it with the first code you provide.

When I run for it under XP to get process of 7, ok.
Here XP represents a machine in network and a VM in the same network area, guess what is common for all the machines including host: when username and password are same, there is no problem running for it. At first, my VM has a different name and no password and it stucks but when I create another account with the same username password, the vbs code works.

Right now, I am trying your C# code, but this time adding some username and password authentication lines which I couldn't solve so far.

Regards.
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0
x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 e
rrorCode, IntPtr errorInfo)
   at System.Management.ManagementScope.InitializeGuts(Object o)
   at System.Management.ManagementScope.Initialize()
   at System.Management.ManagementObject.Initialize(Boolean getObject)
   at System.Management.ManagementClass.GetInstances(EnumerationOptions options)

   at GetPidsFromRemoteHost.Program.GetProcesses(String hostname) in C:\VSWorks\
PIDder\PIDder\Program.cs:line 38

Open in new window

0
jazzIIIloveAuthor Commented:
I added the following for authentication but no avail.

I am on it.
ConnectionOptions oConn = new ConnectionOptions();
            oConn.Impersonation = ImpersonationLevel.Impersonate;
                        
            ManagementScope scope = new ManagementScope("\\\\" + hostname + "\\root\\cimv2");
            scope.Options.EnablePrivileges = true;
            scope.Options.Impersonation = ImpersonationLevel.Impersonate;
            scope.Options.Authentication = AuthenticationLevel.Call;
            scope.Options.Impersonation = ImpersonationLevel.Impersonate;
            //scope.Options.Username = "192.168.2.8\\baran";
            scope.Options.Username = "baran";
            scope.Options.Password = "1234";

Open in new window

0
jazzIIIloveAuthor Commented:
Below code is working from guest XP to host 7-64 bit

but not working from guest XP to another XP in the network.
but not working from host 7-64 bit to guest XP.

Why? What could be the reason?

            ManagementScope scope = new ManagementScope("\\\\" + hostname + "\\root\\CIMV2");
            scope.Options.EnablePrivileges = true;
            scope.Options.Impersonation = ImpersonationLevel.Impersonate;
            scope.Options.Authentication = AuthenticationLevel.Call;
            scope.Options.Impersonation = ImpersonationLevel.Impersonate;
            //scope.Options.Username = "192.168.2.8\\baran";
            scope.Options.Username = "192.168.2.4\\baran";
            scope.Options.Password = "1234";

Open in new window

0
Tech_StigCommented:
Ok, definitely an authentication issue.
First off, are either of these machines on a windows domain? If not what workgroup(s) are they in?

Second, what versions of the operating systems are you running for both Win7 and XP (i.e. Home/Pro/Ent, 32/64)?
0
jazzIIIloveAuthor Commented:
All XPs are pro sp3
7-pro-64bit

no domain, same workgroup as WORKGROUP

An update: I try getting pid of guest XP again from a host XP (not host 7, this time), again error
System.UnauthorizedAccessException: Access Denied. (Exception from HRES
0x80070005 (E_ACCESSDENIED))

Regards
0
jazzIIIloveAuthor Commented:
"Apart from this priviledge", I think we may be also stuck in some point:

http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/aa86c6f7-b2de-48ac-bc82-33ad3a33bcd6/

Ran dcomcnfg from the command prompt.
Selected Windows Management Instrumentation
but the other steps don't fit here. I mean I should be doing stg with WMI, to give some rights to cimv2 in the remote machine, which I already did. All firewalls are closed, AVs are disabled.

What a pain in the ass...:)
0
jazzIIIloveAuthor Commented:
I think we are in this very link:

http://msdn.microsoft.com/en-us/library/aa393266.aspx

1) Which steps should I apply?
2) To the remote machine/guest or local machine/host?
0
jazzIIIloveAuthor Commented:
I applied all the nece. steps in the guest XP and run the program from host XP
in the component services->mycomputer->properties->com security: I added everyone and give all permissions to him. In default properties tab; Default Auth. Connect, default impersonation level->identify

and restart MS DTC.

no avail. note that it doesn't go into exception directly when I run this C# code. He waits for 7-8 seconds then go into exception.

Regards.
0
jazzIIIloveAuthor Commented:
Note that I cannot justify that I cannot reach a VM since:
1) XP VM can reach host 7. Vice-Versa fail. If this vice-versa is possible, then I will close this question gladly:)
2) Two host OSes, XP can reach 7. Vice-versa fail.(no vmware stuff here)

Regards.
0
Tech_StigCommented:
That's interesting. When you ran it from the XP host, was it the same exception as before or a different one? I have replicated everything that you have with one difference, My Win7 host is 32bit. I can get to anything from anywhere. However I have rules in the firewalls to allow the traffic or I have turned it off.

I'd try real quick disabling the firewall on both the win7 host and the xp guest and see what happens.

Also, try setting up a windows share on both the 7 host and XP guest and make sure you can get that to work.

Another thing you can try is adding a vmnic to your XP guest and configuring host-only networking and try this over that.
0
jazzIIIloveAuthor Commented:
All the firewalls are closed. Yes, the exception is same. If the firewall is opened, vbs gives a different error, if the firewall is opened, the vbs error changes. The C# code is again gives System.UnauthorizedAccessException: Access Denied. (Exception from HRES
0x80070005 (E_ACCESSDENIED))

I can ping the machines, windows share is enabled but I didn't share an entire drive.

What is vmnic?

Regards.
0
jazzIIIloveAuthor Commented:
ok, so, you say, your c#.net code is working from host to guest and from guest to host.

If so:
Let me give my properties:
1) I am using VMWare Workstation 7
2) All firewalls and AVs are disabled.
3) Guest OS VM's network stuff is 192.168.2.8, 255.255.255.0, gateway, dns: 192.168.2.1
4) Host OS 192.168.2.4, 255.255.255.0, gateway, dns: 192.168.2.1
5) To obtain guest OS to have this network stuff, i changed the guest OS from NAT to bridged.
6) All the credentials are same in guest and host.
7) No WMI change I have done in the first place and it's working from guest to host, XP to 7 vice versa failed.

So, which step is different from you? or which step am i missing?

Regards.
0
jazzIIIloveAuthor Commented:
XP Pro-32bit-EN
7 Pro-64bit-EN

Surprisingly, XP can reach 7 only. I could have understood the other case, 7 reaching XP but not available in this case.

Regards.
0
Tech_StigCommented:
The only differences for me are the network (mine is 192.168.1.0/24) and my Host OS (Win7 32bit). I'm still using a bridged connection so my guest OS (XP also on VMware workstation 7) is on the same network. Machines are in the same workgroup.

To answer your question from before, a vmnic is a Virtual Machine NIC, Virtual Network adapter, or Virtual NIC. You can give a vm guest multiple network adapters and connect them to different VMNetworks (bridged, NAT, Host-Only)..

Have you tried enabeling Remote Desktop on the guest and try to get to it from the host? I'm probably guessing that's going to fail too. If that does, it's something to do with how the vmware bridge is handling the traffic.


0
jazzIIIloveAuthor Commented:
If I have host-only on guest, then I get the following error which in fact the host machine cannot reach. (Error is something regarding firewall but all firewalls are closed so I infer that host-only ruins it)

System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unav
ailable. (Exception from HRESULT: 0x800706BA)
I cannot ping both ways in this conf.

Note that RDP is enabled in both machines in both ways.

if I have bridged together with replicate the host state:
I get this error: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0
x80070005 (E_ACCESSDENIED))
Note that I can ping both ways.

So, I tihink it must be bridged and the error is:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0
x80070005 (E_ACCESSDENIED))

So, this is definitely a permission issue. Note that above, I think I have given all the rights to the user "Everyone".

One other thing could be the running services. I am sending you all services, that I captured to tab seperated txt file and I change its extension to xls for your ease.

Regards.
guestservices.xls
0
jazzIIIloveAuthor Commented:
I have no IIS installed in the both machines for the record.
0
jazzIIIloveAuthor Commented:
I found this wonderful tool for wmi:
http://www.microsoft.com/downloads/details.aspx?familyid=2CC30A64-EA15-4661-8DA4-55BBC145C30E&displaylang=en

Guess what error I have got if I run this application...Same as System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0
x80070005 (E_ACCESSDENIED))
0
jazzIIIloveAuthor Commented:
ok, I tried for repairing wmi
http://windowsxp.mvps.org/repairwmi.htm

I have a problem "after" repairing that I cannot restart the service and it turns out to be the wmi service user assignment, I have given a spefici account while i try for authentication stuff, I take back the setting and I can start the wmi again after repairing, but still I have the very same problem and I am out of solutions.

Any thing pop up in your head?

Regards.
0
Tech_StigCommented:
WMI should be running as "Local System Account." RPC Should be running as "Network Service."

Take a look at these couple of links. The first one is for another issue but can cause the same symptoms.

http://support.microsoft.com/kb/895085

http://www.calazan.com/wmi-access-is-denied-exception-from-hresult-0x80070005/

Also while in dcomcnfg go to Computers->My Computer->DCOM Config. Right-click on Windows Management and Instrumentation and click properties. Check the permissions on the Security tab and make sure that both the user you are authentication with and System has access. THen check Identity and make sure "The system account" is checked.

After all that I would reboot and try again...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jazzIIIloveAuthor Commented:
Tech_Stig you save the day:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VMware

From novice to tech pro — start learning today.