PowerShell or Command Prompt script to check for specific process

britechguy

Well-Known Member
Reaction score
4,041
Location
Staunton, VA
First, I'll admit that I'm being lazy by not web searching on this, but I figure several someones here will know the answer and the quality of answer will probably be better.

If I'm looking to determine if a process, or cluster of related processes, is running and I don't care about any others, is there a tidy command or piped sequence I can use to get that information?

As a for instance, say the Thunderbird email client had been running, but has been closed, and you believe you had your settings such that it should not leave anything running in the background when you do. But, strangely enough, you keep getting new email arrival notifications. Is there a "quick and dirty" way to check via either PowerShell or Command Prompt whether a Thunderbird process of some sort remains active?

I ask this question mostly for some of the blind and visually impaired folks I work with. Using Task Manager or Process Monitor or any of the usual utilities is generally a nightmare with a screen reader. And if you know the name (or a decent part of it) of the process you're looking for it's far easier to use a CLI to get that info in an accessible way.
 

Get-Service. But I'm not sure how well that would work with a screen reader because of all of the necessary syntax formatting. Though it should be possible to pipe the output of dependent processes to kill each one. Are you specifically looking at Tbird? Most modern email clients are/can be setup to receive emails even when "closed". Or are you thinking about zombie processes in general Brian?
 
Tasklist piped through Findstr is one way to do part of this.

tasklist | findstr -i chrome.exe

will tell you if chrome is running. Perhaps not useful as chrome is always running. :)

Don't know how to get "related" processes without knowing their name, though -


Edit: Ooh, wmic can give you the parent PID of all PIDs running like this:

wmic process get processid,parentprocessid

I am a firm believer that WMIC is at once the most powerful and most under-appreciated program in Windows.
 
Last edited:
Code:
Get-Process | Where-Object { $_.MainWindowTitle } | Format-Table ID,Name,Mainwindowtitle –AutoSize

That command will list applications running under the given user context, DO NOT RUN AS ADMIN. And ONLY applications. So any user facing stuff that's hung up or not should be there.
 
The question arose directly in reference to Thunderbird, but I know that the situation can arise more generally.

I'm no so much looking for killing capability as I am for verifying something's still running. Someone on the NVDA group suggested Get-Process, too.

As with so many things in Windows, there are multiple roads to Rome.
 
Back
Top