Page 1 of 1

Registry key to find installation directory

Posted: 13 Mar 2013 06:35
by happiness
H all,

I'm looking for a way to find (and run) a program that can be installed anywhere on the PC.

I've found some code that lists all the installed programs on the PC, from this, is there a way to extract the "InstallLocation" of a specific program then run the *.exe?

Here's what I'm using to compile a list of installed programs:

Code: Select all

@echo off

If Exist c:\installedprogs.txt Del c:\installedprogs.txt
regedit /e c:\regexport.txt "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall"

find "DisplayName" c:\regexport.txt >c:\regprogs.txt
for /f "tokens=2 delims==" %%a in (c:\regprogs.txt) do echo %%~a >>c:\installedprogs.txt

del c:\regexport.txt
del c:\regprogs.txt

exit

Re: Registry key to find installation directory

Posted: 13 Mar 2013 07:32
by foxidrive
You can get the uninstall string which seems to have the programs home directory in it.

What do you need to do? Do you want to run the exe file?

Re: Registry key to find installation directory

Posted: 13 Mar 2013 09:31
by mfm4aa
You can use somewhat like this on the command line (if 'DisplayName' is the name of the installed program):

Code: Select all

for /f "tokens=2*" %i in ('reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\DisplayName" /v "InstallLocation"^|find "REG_SZ"') do @echo %~j

Re: Registry key to find installation directory

Posted: 13 Mar 2013 15:52
by foxidrive
@mfm4aa: I found viewing my registry that few programs give an 'InstallLocation'

As an example, this is all that 7-zip has.

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip]
"DisplayName"="7-Zip 9.20"
"NoModify"=dword:00000001
"NoRepair"=dword:00000001
"UninstallString"="\"C:\\Program Files\\7-Zip\\Uninstall.exe\""