%GetProgPath%    Show Routine Code    Author: Siegfried   ... using work from MartinR


Version: 1  -  Date: 2007-02-15

 

Example calls:
%GetProgPath% "HKLM\Software\PowerQuest\PartitionMagic\8.0\UserInfo" "Install Path"
%GetProgPath% "HKEY_LOCAL_MACHINE\SOFTWARE\Acronis\DiskDirector\Settings" "ExePath"
%GetProgPath%

Remarks:
Searches the registry for the installation path of a program and returns the result to the calling script in a variable %ProgPath%.
My extended ProgPath routine is based on the original ProgPath script by MartinR. It adds an addl. attempt to find the path by searching for the MainExe in ProgramFiles if everything else failed. Authors having problems to find a suitable registry entry for the ProgPath can now just use "%GetProgPath%" and will get a result. It may just take a while to search for the path that way.

%GetProgPath% like in example 3 will already find the ProgPath in the registry for some programs like Nero, which store the path in the standard location in registry.
The definition of the main exe in autoHelp.cmd is used for this attempt as well as for the MainExe search in ProgramFiles.

If ProgPath is "NotFound" after the search in registry, a last try will be made searching the entire %ProgramFiles% directory for the %MainEXE%.
If that fails too, ProgPath will be returned as "NotFound". If successful, the %ProgPath% is returned without a trailing backslash.

NOTE: it is essential that you define %MainEXE% in your AutoHelp.cmd as it is needed to check the success of the various attempts to find the ProgPath.