G
Guest
I use the following method to stop the WMI service:
string serviceName = "Windows Management Instrumentation"
public static void stopService(string serviceName)
{
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController svc in services)
{
if (svc.DisplayName == serviceName)
{
try
{
svc.Stop();
}
catch (System.ServiceProcess.TimeoutException ex)
{
Console.WriteLine(ex.Message);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("The {0} process was stopped.",
serviceName);
}
}
}
According to Event Viewer the system is sent a stop control to WMI, and then
the service stops. A second or so later the WMI service restarts for no
apparent reason. Any advice on how to keep the WMI service stopped would be
greatly appreciated. I am new to C# so if you see any problems with my
method or can suggest a better way to do this please let me know. Thanks in
advance.
string serviceName = "Windows Management Instrumentation"
public static void stopService(string serviceName)
{
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController svc in services)
{
if (svc.DisplayName == serviceName)
{
try
{
svc.Stop();
}
catch (System.ServiceProcess.TimeoutException ex)
{
Console.WriteLine(ex.Message);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("The {0} process was stopped.",
serviceName);
}
}
}
According to Event Viewer the system is sent a stop control to WMI, and then
the service stops. A second or so later the WMI service restarts for no
apparent reason. Any advice on how to keep the WMI service stopped would be
greatly appreciated. I am new to C# so if you see any problems with my
method or can suggest a better way to do this please let me know. Thanks in
advance.