Registry key to find installation directory

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
happiness
Posts: 6
Joined: 08 Mar 2013 18:02
Location: Dinnington, Newcastle upon Tyne, UK
Contact:

Registry key to find installation directory

#1 Post by happiness » 13 Mar 2013 06:35

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Registry key to find installation directory

#2 Post by foxidrive » 13 Mar 2013 07:32

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?

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: Registry key to find installation directory

#3 Post by mfm4aa » 13 Mar 2013 09:31

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Registry key to find installation directory

#4 Post by foxidrive » 13 Mar 2013 15:52

@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\""

Post Reply