I need to programmatically get a list of running applications as shown in the "Applications" tab inside the Windows Task Manager using PowerShell or VBScript.
All I could find so far is how to list processes using VBScript and WMI.
I need to programmatically get a list of running applications as shown in the "Applications" tab inside the Windows Task Manager using PowerShell or VBScript.
All I could find so far is how to list processes using VBScript and WMI.
This should do the trick.
Set Word = CreateObject("Word.Application")
Set Tasks = Word.Tasks
For Each Task in Tasks
If Task.Visible Then Wscript.Echo Task.Name
Next
Word.Quit
This gets you close in PowerShell:
get-process | where-object {$_.mainwindowhandle -ne 0} | select-object name, mainwindowtitle
Or the shorter version:
gps | ? {$_.mainwindowhandle -ne 0} | select name, mainwindowtitle
stahler's answer converted to PowerShell:
$word = new-object -com 'word.application'
$word.tasks | ? {$_.visible} | select name
$word.quit()
@Steven Murawski: I noticed that if I used mainwindowhandle I'd get some process that were running, of course, but not in the "Applications" tab. Like explorer and UltraMon, etc. You could condition off of mainwindowtitle instead, since those process I encountered didn't have window titles -- like so
gps | ? {$_.mainwindowtitle.length -ne 0} | select name, mainwindowtitle