Hi,
I am Connecting ti remote computer using C# WMI through the following code.But i t gives Some error "INVALID PARAMETERS" at scop.Connet
Is there any procedure to coonect to rempte pc with authentication and start and stop the remote pc Windows services.
plse suggest me any modification in the code and tell mw the other code . Its Urgent.
Thanks
Prasad.
I am Connecting ti remote computer using C# WMI through the following code.But i t gives Some error "INVALID PARAMETERS" at scop.Connet
Is there any procedure to coonect to rempte pc with authentication and start and stop the remote pc Windows services.
plse suggest me any modification in the code and tell mw the other code . Its Urgent.
Code:
try { ConnectionOptions connection = new ConnectionOptions(); connection.Username = userNameBox.Text; connection.Password = passwordBox.Text; connection.Authority = "ntlmdomain:DOMAIN"; ManagementScope scope = new ManagementScope( "\\\\FullComputerName\\root\\CIMV2", connection); scope.Connect(); ObjectQuery query= new ObjectQuery( "SELECT * FROM Win32_Service"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); foreach (ManagementObject queryObj in searcher.Get()) { Console.WriteLine("-----------------------------------"); Console.WriteLine("Win32_Service instance"); Console.WriteLine("-----------------------------------"); Console.WriteLine("Caption: {0}", queryObj["Caption"]); Console.WriteLine("Description: {0}", queryObj["Description"]); Console.WriteLine("Name: {0}", queryObj["Name"]); Console.WriteLine("PathName: {0}", queryObj["PathName"]); Console.WriteLine("State: {0}", queryObj["State"]); Console.WriteLine("Status: {0}", queryObj["Status"]); } Close(); } catch(ManagementException err) { MessageBox.Show("An error occured while querying for WMI data: " + err.Message); }
Prasad.
Comment