Skip navigation

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


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_MACHINE\SOFTWARE\Classes\Applications\<Program>\Shell registry key, where <Program> is the program name, like WINWORD.EXE or OUTLOOK.EXE.

I have scripted WhatPath.bat to return the FQFN if it is available at HKLM\SOFTWARE\Classes\Applications\<Program>\shell.

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 off
if \{%2\}==\{\} @echo Syntax WhatPath Program.exe FQFN&goto :EOF 
setlocal ENABLEDELAYEDEXPANSION
set prog=%1
set prog=%prog:"=%
set pp=%prog%
set OK=N
call :quiet>nul 2>&1
if /i "%pp:~0,12%" NEQ "rundll32.exe" set pp="%pp%"
endlocal&set %2=%pp%
goto :EOF
:quiet
set qry=reg query "HKLM\SOFTWARE\Classes\Applications\%prog%\shell" /s
for /f "Tokens=2*" %%a in ('%qry%^|find "<NO NAME>"^|find "REG_"^|find /i "%prog%"') do (
 if "!OK!" EQU "N" call :setpp %%b
)
goto :EOF
:setpp
set OK=Y
set pp=%2
set pp=%pp:"=%
if /i "%pp%" EQU "rundll32.exe" set pp=%2 %3,%4&goto :EOF
:prd
If \{%3\} EQU \{\} goto :EOF
set wrk=%pp:.=%
if "%wrk%" NEQ "%pp%" goto :EOF
set pp=%pp%%3
shift /4



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish