JSI Tip 10110. How can I retrieve the Fully Qualified File Name of an installed Program.exe?

Jerold Schulman

January 31, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today


Many installed programs that are NOT necessarily in your %PATH% have their FQFN at the default Value Name of a Command sub-key of the HKEY_LOCAL_MACHINESOFTWAREClassesApplicationsShell registry key, where is the program name, like WINWORD.EXE or OUTLOOK.EXE.

I have scripted WhatPath.bat to return the FQFN if it is available at HKLMSOFTWAREClassesApplicationsshell.

The syntax for using WhatPath.bat is:

[Call] WhatPath Program.exe FQFN

Where:

Program.exe is the program name, like WINWORD.EXE or OUTLOOK.EXE.FQFN        is a call directed environment variable that will contain the FQFN            (Fully Qualified File Name) of Program.exe.

WhatPath.bat contains:

@echo offif {%2}=={} @echo Syntax WhatPath Program.exe FQFN&goto :EOF setlocal ENABLEDELAYEDEXPANSIONset prog=%1set prog=%prog:"=%set pp=%prog%set OK=Ncall :quiet>nul 2>&1if /i "%pp:~0,12%" NEQ "rundll32.exe" set pp="%pp%"endlocal&set %2=%pp%goto :EOF:quietset qry=reg query "HKLMSOFTWAREClassesApplications%prog%shell" /sfor /f "Tokens=2*" %%a in ('%qry%^|find ""^|find "REG_"^|find /i "%prog%"') do ( if "!OK!" EQU "N" call :setpp %%b)goto :EOF:setppset OK=Yset pp=%2set pp=%pp:"=%if /i "%pp%" EQU "rundll32.exe" set pp=%2 %3,%4&goto :EOF:prdIf {%3} EQU {} goto :EOFset wrk=%pp:.=%if "%wrk%" NEQ "%pp%" goto :EOFset pp=%pp%%3shift /4



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like