I need to use a REG QUERY command to view the value of a key and set the result into a variable with this command:
FOR /F \"tokens=2* delims= \" %%A IN (\
@echo off
setlocal ENABLEEXTENSIONS
set KEY_NAME=HKLM\SOFTWARE\Wow6432Node\Acme Software Inc\Common
set VALUE_NAME=InstallDir
FOR /F "tokens=2*" %%A IN ('REG.exe query "%KEY_NAME%" /v "%VALUE_NAME%"') DO (set pInstallDir=%%B)
echo %pInstallDir%
That works for me in Win7 where the key has a space and the value also has a space. So saving the above in c:\temp as test.bat, open a cmd window and run it.
C:\temp>test
C:\Program Files (x86)\acme Software Inc\APP\