How to get list of running applications using PowerShell or VBScript

前端 未结 5 699
鱼传尺愫
鱼传尺愫 2020-12-17 10:34

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

相关标签:
5条回答
  • 2020-12-17 11:08

    stahler's answer converted to PowerShell:

    $word = new-object -com 'word.application'

    $word.tasks | ? {$_.visible} | select name

    $word.quit()

    0 讨论(0)
  • 2020-12-17 11:17

    @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
    
    0 讨论(0)
  • 2020-12-17 11:18

    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
    
    0 讨论(0)
  • 2020-12-17 11:25

    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
    

    http://msdn.microsoft.com/en-us/library/bb212832.aspx

    0 讨论(0)
  • 2020-12-17 11:25

    from command line you are looking for:

    tasklist /v the /v means verbose and will include list of "application running off each process

    tasklist /v /fi "imagenaem eq POWERPNT.EXE" for example can be used to filter just application running under POWERPNT.EXE process.

    0 讨论(0)
提交回复
热议问题