Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting if a program is installed and where using cmd.exe

Windows has the program start.exe which somehow knows how to open programs by their lay-name like "firefox"

Typing start firefox into cmd.exe opens firefox assuming its installed. Is there a similar command to start that will return the file path rather than starting the application?

Also open to any similar but proper solution

UPDATE: Other answers suggest using where command, and this works for programs like ping which are in the system directories, but does not find firefox like start does.

like image 423
Nowayz Avatar asked Feb 01 '14 22:02

Nowayz


1 Answers

Take a look at this registry key.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

In it you will find something similar to this for firefox.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe]
@="C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"
"Path"="C:\\Program Files (x86)\\Mozilla Firefox"

and here is a bit that reads the value from Powershell. Same thing can be done from batch file with reg.exe.

$Firepath = get-item -path 'registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe'
$Firepath.GetValue('')
like image 133
Knuckle-Dragger Avatar answered Nov 14 '22 23:11

Knuckle-Dragger