It opens a registry subkey value (this subkey value contains the path to an .exe; it is called "Location"). It opens the .exe fine but the command window stays open and I have tried everything to close it.
To try it out on your own pc you can change the registry value I have (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\Programpath) to one on your own pc. Also this registry value has to have the subkey "Location".
I would appreciate any help, thanks.
Code: Select all
@echo off
set TESTK=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\Programpath
set TESTV=Location
call :reg_read "%TESTK%" "%TESTV%" "exit" || (echo ERROR: no value found for Location & exit /b 1)
:reg_read <key> <value>
setlocal
set key=%~1
set value=%~2
REM // make one call to reg to make sure the KEY/VALUE exists before reading it
reg query "%key%" /v "%value%" 1>nul 2>&1 || (exit /b 1)
for /f "tokens=2,*" %%a in ('reg query "%key%" /v "%value%" ^| findstr /c:"%value%"') do (
%%b
)