List the current processesTag(s): WSH VBScript


This script will the current running processes names with PIDs and command lines.
Set Processes = GetObject _
                 ("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")_
                 .ExecQuery("select * from Win32_Process")
For each Process in Processes
   PList = PList & Process.ProcessId & _
           " " & Process.Name & " " & _
           Process.CommandLine & vbLf
Next
WScript.Echo PList
To redirect the output to a file, make sure to use the console interpreter and use the stdout redirection to a file.
cscript /nologo plist.vbs >currentprocess.txt
output :
2452 taskhost.exe "taskhost.exe"
772 dwm.exe "C:\Windows\system32\Dwm.exe"
2836 explorer.exe C:\Windows\Explorer.EXE
2468 RAVCpl64.exe "C:\Program Files\Realtek\Audio\HDA\RAVCpl64.exe"
1204 jusched.exe "C:\Applications\dev\jre6\bin\jusched.exe"
1152 GoogleToolbarNotifier.exe "C:\Program Files (x86)\Google\GoogleToolbarNotifier\GoogleToolbarNotifier.exe"
...

blog comments powered by Disqus