|
-
July 8th, 2008, 03:31 AM
#1
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|