How to get running processes with PowerShell using WMI and display its path.
PowerShell below will display the path and also the command line of the process on how the process was executed.
The code below will also display the process-id, the process-id or PID can also be supplied to an application called handle64 from SysInternal tools. This tool is quite cool since it will display more info about the PID supplied to handle application.
Download link for handle64: https://docs.microsoft.com/en-us/sysinternals/downloads/handle
Example output of handle64:
Skype.exe pid: 42360 DESKTOP-Name\iuser-xname
40: File C:\Windows
84: File C:\Program Files (x86)\Microsoft\Skype for Desktop
24C: File C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b23cb64144ccf1df_6.0.19041.1_none_fd031af4F787f5b0106f2
380: File C:\Windows\System32\en-US\mswsock.dll.mui
3A0: File C:\Users\iuser-~1\AppData\Local\Temp\skype-preview Crashes\operation_log.txt
3C4: File C:\Users\iuser-~1\AppData\Local\Temp\skype-preview Crashes\CrashpadMetrics-active.pma
3D0: Section \Windows\Theme2059671484
3D4: Section \Sessions\1\Windows\Theme3966775245c43435
PowerShell code to display processes:
Get-WmiObject -Query “SELECT * FROM Win32_Process” | Ft ExecutablePath, ProcessId, CommandLine -wrap
Sample output:
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
697072 "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--type=renderer --field-trial-handle=10572,1079634
77934539454521501883579,116308618535245426994419,131530072
--lang=en-US --enable-auto-reload
--device-scale-factor=1.25
--num-raster-threads=4
--enable-main-frame-before-activation
--renderer-client-id=204
--no-v8-untrusted-code-mitigations
--mojo-platform-channel-handle=697072 /prefetch:1
That's it if need to troubleshoot or just need to peek around the running processes or application, above code will be able to do such task. Or if there is a need to check how the command line was launched, the PowerShell command line output displays on how the application was launch via command line.
To stop or terminate running processes via command line check out this link: https://quickbytesstuff.blogspot.com/2016/01/windows-get-running-processes.html
Cheers...till next time. Stay safe and keep praying that this pandemic will end.
================================
Heaven's Dew Fall Prayer app for Android :
https://play.google.com/store/apps/details?id=com.myrosaryapp
Comments
Post a Comment