Finding what svchost is looping
September 5th, 2007
Every notice your windows machine going slow. Gone into task manager, sorted by CPU time and notices svchost going like a bat in chocolate ( hmmmmmm, chocolate bats … ). svchost.exe is a container for many other processes that run in the background of your windows machine. Some are nice, some are evil. Some are required, some not so much. But how can you tell exactly what that svchost is responsible for. You can try this script. Copy into notepad and save as “something.vbs”. The run it. It will pop up a dialog with a list of PIDs and what they are responsible for. If you don’t think you need it, kill it in taskmanager.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | set objIdDictionary = CreateObject("Scripting.Dictionary") strComputer = "." strReturn = "" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colServices = objWMIService.ExecQuery _ ("Select * from Win32_Service Where State <> 'Stopped'") For Each objService in colServices If objIdDictionary.Exists(objService.ProcessID) Then Else objIdDictionary.Add objService.ProcessID, objService.ProcessID End If Next colProcessIDs = objIdDictionary.Items For i = 0 to objIdDictionary.Count - 1 Set colServices = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Service WHERE ProcessID = '" & _ colProcessIDs(i) & "'") strReturn = strReturn & "Process ID: " & colProcessIDs(i) & Chr(13) For Each objService in colServices strReturn = strReturn & VbTab & objService.DisplayName & Chr(13) Next Next Wscript.Echo strReturn |