More zombie process destroying scripts

Kill Your Zombie Process I wrote an article a few months back entitled Killing zombie Google Chrome processes. In the post, I talk about the fact Google Chrome can spin off multiple processes during a browsing session. When you close the browser window sometimes Chrome can leave behind several zombie processes in the Windows Task Manager.

Within the article, I presented two ways to solve this problem. I showed a PowerShell command and I also mentioned a fix through a batch script I created. I uploaded a copy of the Stop Google Chrome Processes batch script file to the TechNet Gallery.

Since then, I have created a similar batch file for other web browsers including Firefox, Explorer, Edge and Opera. All can be downloaded from the TechNet Gallery via the links below.

Advertisements

Killing zombie Google Chrome processes

This article is also available on the Microsoft TechNet Wiki.

When using the Google Chrome browser with of mix of normal and incognito windows, long-running sessions with multiple tabs can sometimes chew up a lot of memory. It certainly does not help either that Google Chrome spawns 10+ processes for any given browsing session. So when it comes time to close these browsing sessions it is not uncommon for Chrome to leave behind several zombie processes in the Windows Task Manager.

ChromeProcesses01

To terminate these remaining processes you can right-click them in the Task Manager and select End task. However, there is a faster way using either a PowerShell command or Windows Batch (.bat) file. Let’s examine both ways.

PowerShell

Within PowerShell, there is the Stop-Process Cmdlet. This will allow you to terminate all processes in one command. You can kill the process either by process name (minus the file extension) or by process ID. Since we want to end all Chrome processes, we would use the -processname parameter combined with the process name:

Stop-Process -processname Chrome

You can enter this command into the PowerShell window or save it to a PowerShell script (.ps1) file that you can run from the Windows PowerShell ISE.

Batch File

Another, simpler, way is to create a Batch (.bat) file. A batch file is a script used in Windows. It lists commands that can be run using the command line interpreter when the file is either called from the Command Prompt or double-clicked.

To stop processes, we can execute the taskkill command:

taskkill /F /IM chrome.exe /T

This command will use these parameters:

  • /F: Identifies that process(es) be forcefully killed.
  • /IM: Identifies the image name of the process to be killed
  • /T: Kills all child processes along with the parent process, commonly known as a tree kill
    If we combine this with a For Loop we can see the number of processes being terminated:

ChromeProcesses02

When run, the script will pause to display all terminated processes including the associated process ID (PID). As well, the total number of Google Chrome processes removed is also listed.

Conclusion

In this article, we saw how we can use both a PowerShell command and a Batch file to terminate hanging or zombie Google Chrome processes. Try either method if you have problems with Chrome processes remaining on your machine after all sessions are closed.

Script

Download a copy of this Batch script file from the TechNet Gallery:

References