August 4, 2016 Leave a comment
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.
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.
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.
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:
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.
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.
Download a copy of this Batch script file from the TechNet Gallery: