The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,183 other subscribers

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/ArchiveSpring.Tests unit tests instances of [Wayback/ArchiveSpring4D were running.

This case I needed to see which DevEnv were running (because somehow I got my .csproj bindings wrong).

Since [Wayback/Archivetasklist nor [Wayback/Archivepslist would cut it, I wrote two small batch files:

[Wayback/Archive] :

[Wayback/Archive] :

@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/ArchiveGet-Process cmdlet.

First I used [Wayback/ArchiveGet-Member to see what Get-Process could return:

PowerShell Get-Process ^| Get-Member

Then I [Wayback/Archivefiltered 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

2 Responses to “Get the full exe path name of running processes.”

  1. Since you’re using powershell, wouldn’t (gps ).path do the same?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: