Get the full exe path name of running processes.
Posted by jpluimers on 2016/02/03
Every once in a while, I need to see which EXE paths.
In [Wayback/Archive] this particular case, I wanted to see which [Wayback/Archive] Spring.Tests unit tests instances of [Wayback/Archive] Spring4D were running.
This case I needed to see which DevEnv were running (because somehow I got my .csproj bindings wrong).
Since [Wayback/Archive] tasklist nor [Wayback/Archive] pslist would cut it, I wrote two small batch files:
[Wayback/Archive] list-running-processes.bat:
| :: http://technet.microsoft.com/en-us/library/hh849832.aspx | |
| PowerShell Get-Process |
[Wayback/Archive] get-Full-Exe-Path-of-a-Running-Process.bat:
@echo off :: http://superuser.com/questions/768984/show-exe-path-of-running-processes-on-the-command-line-in-windows if [%1] == [] goto :help PowerShell Get-Process %* ^| Format-List Path goto :eof :help echo Syntax: echo %0 ProcessName echo Shows the full EXE paths of any running process with the ProcessName name. echo Example: echo %0 DevEnv echo Shows the paths of running Visual Studio processes
PowerShell to the rescue here: Both batch files use the PowerShell [Wayback/Archive] Get-Process cmdlet.
First I used [Wayback/Archive] Get-Member to see what Get-Process could return:
PowerShell Get-Process ^| Get-Member
Then I [Wayback/Archive] filtered the Path from Get-Process to figure out which Spring.Tests processes were running:
PowerShell Get-Process Spring.Tests ^| Format-List Path
resulting in:
Path : C:\Users\Developer\Versioned\Spring4D\Tests\Bin\DelphiXE\Spring.Tests.exe
The second batch file escapes the pipe (|) by using a carret (^), so it is passed from the command-line to PowerShell.
–jeroen






Michael Estl said
Since you’re using powershell, wouldn’t (gps ).path do the same?
Michael Estl said
Ah you put the path in a format….. that was out of view on my tablet. (:
Why wrap this in a batchfile?