Windows – Automatically find installation directory of application and run batch command inside folder

batchcommand linewindows

Basically, assume I have program called ABCD installed.

I want to automatically find out where exactly (which folder) it is installed (sometimes not installed in C drive, that's why), and run a batch file command inside that folder.

An idea I'm having is to check for the name in control panel programs list automatically, but I don't know how.

Best Answer

Is there a way to dynamically determine where Adobe Acrobat Pro DC is installed?

I don't have Adobe Acrobat Pro DC installed but here is a batch file that determines where Adobe Acrobat Reader is installed.

You should be able to modify this to find Adobe Acrobat Pro DC instead.

The following batch file (test.cmd) will determine where Adobe Reader is installed and sets the _acrobat_path environment variable to this value:

@echo off
setlocal
setlocal enabledelayedexpansion
for /f "usebackq tokens=3*" %%a in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Adobe\Acrobat Reader\DC\InstallPath" /s`) do (
  set _acrobat_path=%%a %%b
  echo !_acrobat_path!

  )
endlocal

Example output:

F:\test>test
C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader
F:\test>

Further Reading

Related Question