ademartini
ademartini

Reputation: 1441

Windows CMD - Run program and specify image name

I would like to run a program from the commandline (or batch file) but specify the imagename that shows up in the task manager. Is this possible using windows CMD?

This is something that needs to be done in a batch script or as a command-line argument, not by renaming the exe itself.

Upvotes: 1

Views: 6265

Answers (1)

TessellatingHeckler
TessellatingHeckler

Reputation: 29033

From a command prompt you can use c:\> title MyCustomTitle and then they show up in TaskManager (Windows 8) like this:

Screenshot of Task Manager with custom title in cmd.exe

So you could tell them apart that way. I don't know of a way to change the icon, and setting a shortcut with a custom icon doesn't work.

EDIT

Suggestion 2: Copy c:\windows\system32\cmd.exe and rename it, then run that.

Screenshot of Task Manager with renamed cmd.exe

EDIT 2

Since This Microsoft KB Article on CreateProcess makes me think it's not possible to do what you want, how about a WMI query that shows you running processes and their process ID, and you can run it after every launch and see what the new process ID is?

e.g. batch file

wmic PROCESS WHERE (Name="notepad.exe") GET ProcessId
rem up to you to keep track of previously seen processes

PowerShell

$knownProcessIds= @()
$processIds = Get-WmiObject Win32_Process -filter 'Name="notepad.exe"' | select -ExpandProperty ProcessId
$newProcessId = $ProcessIds | ? {$knownProcessIds -notcontains $_}
$knownProcessIds += $newProcessId
Write-Output "New notepad instance is $newProcessId"

Upvotes: 5

Related Questions