Monday, April 19, 2010

Showing Services on a Remote System

private void showServices(string temp1)

{

try

{

ConnectionOptions connection = new ConnectionOptions();

ManagementScope scope = new ManagementScope(

"\\\\" + temp1 + "\\root\\CIMV2", connection);

scope.Connect();

ObjectQuery query = new ObjectQuery(

"SELECT * FROM Win32_Service");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

txtPing.Text = "-----------------------------------" + "\r\n";

txtPing.Text += "Services on " + temp1 + "\r\n";

txtPing.Text += "-----------------------------------" + "\r\n";

foreach (ManagementObject queryObj in searcher.Get())

{

txtPing.Text += "Caption: {0}" + queryObj["Caption"] + "" + "\r\n";

txtPing.Text += "Description: {0}" + queryObj["Description"] + "\r\n";

txtPing.Text += "Name: {0}" + queryObj["Name"] + "\r\n";

txtPing.Text += "PathName: {0}" + queryObj["PathName"] + "\r\n";

txtPing.Text += "State: {0}" + queryObj["State"] + "\r\n";

txtPing.Text += "Status: {0}" + queryObj["Status"] + "\r\n";

txtPing.Text += "-----------------------------------" + "\r\n";

}

}

catch (ManagementException ex)

{

mnuNotify.ShowBalloonTip(

5000,

"NetPinger 2010: " + temp1,

ex.Message,

ToolTipIcon.Warning);

toolStripStatusLabel1.Text =

ex.Message + " , services aren't available";

}

} private void showServices(string temp1)

{

try

{

ConnectionOptions connection = new ConnectionOptions();

ManagementScope scope = new ManagementScope(

"\\\\" + temp1 + "\\root\\CIMV2", connection);

scope.Connect();

ObjectQuery query = new ObjectQuery(

"SELECT * FROM Win32_Service");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

txtPing.Text = "-----------------------------------" + "\r\n";

txtPing.Text += "Services on " + temp1 + "\r\n";

txtPing.Text += "-----------------------------------" + "\r\n";

foreach (ManagementObject queryObj in searcher.Get())

{

txtPing.Text += "Caption: {0}" + queryObj["Caption"] + "" + "\r\n";

txtPing.Text += "Description: {0}" + queryObj["Description"] + "\r\n";

txtPing.Text += "Name: {0}" + queryObj["Name"] + "\r\n";

txtPing.Text += "PathName: {0}" + queryObj["PathName"] + "\r\n";

txtPing.Text += "State: {0}" + queryObj["State"] + "\r\n";

txtPing.Text += "Status: {0}" + queryObj["Status"] + "\r\n";

txtPing.Text += "-----------------------------------" + "\r\n";

}

}

catch (ManagementException ex)

{

mnuNotify.ShowBalloonTip(

5000,

"NetPinger 2010: " + temp1,

ex.Message,

ToolTipIcon.Warning);

toolStripStatusLabel1.Text =

ex.Message + " , services aren't available";

}

}


No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...