modules/InstallationSDK.ChefClientInstaller/code/WindowsService.cs
/// <summary>
/// Locate process by service name and kill it and its spawn.
/// </summary>
Locate process by service name and kill it and its spawn.
Locate process by service name and kill it and its spawn .
private void KillService()
        {
            var searcher = new ManagementObjectSearcher(
                "SELECT * " +
                "FROM Win32_Service " +
                "WHERE Name=\"" + Name + "\"");
            var collection = searcher.Get();
            foreach (var item in collection)
            {
                var serviceProcessId = (UInt32)item["ProcessId"];
                KillSpawnedProcesses(serviceProcessId);
                Trace.TraceInformation("{0} - Killing Service process with Id [{1}].", Name, serviceProcessId);
                KillProcess(serviceProcessId);
            }
        }
private void KillService ( ) { var searcher = new ManagementObjectSearcher ( " " + " " + " \" " + Name + " \" " ) ; var collection = searcher . Get ( ) ; foreach ( var item in collection ) { var serviceProcessId = ( UInt32 ) item [ " " ] ; KillSpawnedProcesses ( serviceProcessId ) ; Trace . TraceInformation ( " " , Name , serviceProcessId ) ; KillProcess ( serviceProcessId ) ; } }
Locate process by service name and kill it and its spawn.
Locate process by service name and kill it and its spawn .