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 this particular case, I wanted to see which Spring.Tests unit tests instances of Sprnig4D werere running.
This case I needed to see which DevEnv were running (because somehow I got my .csproj bindings wrong).
Since tasklist nor pslist would cut it, I wrote two small batch files:
:: http://technet.microsoft.com/en-us/library/hh849832.aspx | |
PowerShell Get-Process |
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 use the PowerShell Get-Process cmdlet.
First I used Get-Member to see what Get-Process could return:
PowerShell Get-Process ^| Get-Member
Then I 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?