CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2008
    Posts
    5

    WMI Connection Error to remote machine

    Hi - I'm trying to use WMI to query a remote machine and get process information. Locally my program worked great, but the remote connection gives me a ManagementException "user credentials cannot be used for local connections." Here is my code:

    using System.Management;
    //....
    ManagementScope scope = new ManagementScope(new ManagementPath("\\\\xp-remote02"));
    scope.Options.user = "mike";
    scope.Options.Password= "tike";
    scope.Options.Authentication= AuthenticationLevel.PacketPrivacy;
    // Formulate the query - SELECT * FROM Win32_Process WHERE Name LIKE "%dev%"
    ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Process WHERE Name LIKE \"%dev%\"");

    //Execute the query
    ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);

    //Get the results
    ManagementObjectCollection collection = searcher.Get();

    //loop and write to console
    foreach( ManagementObject mgt in collection)
    {
    Console.WriteLine(mgt["Name"].ToString());
    }

    //....

    The error points to the row containing searcher.Get(). I'd really appreciate help on this one - thanks.

  2. #2
    Join Date
    Jul 2008
    Posts
    5

    Re: WMI Connection Error to remote machine

    Is it even possible to remote connect or am I just waiting my time? Why do I keep getting that error?...

  3. #3
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: WMI Connection Error to remote machine

    it is obvious in the error message that your computer has no admin rights (policy) to access remote computers' in your network area. checkout with your network admin, he should provide you with the right GPO
    Busy

  4. #4
    Join Date
    Jul 2008
    Posts
    5

    Re: WMI Connection Error to remote machine

    I have access to the remote machine via remote-desktop-connection (as simple user). Does that mean I can't access it with WMI unless I have admin privileges?
    Last edited by sa125; July 11th, 2008 at 05:13 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured