batch file - Reading registry value's data with spaces -
i making program. when installed, run batch file needs know application folder is.
the installation wizard software using creates registry key represents program's path, "program files" has space in it, batch output "c:\program"
my current script is:
@echo off setlocal enableextensions set key_name="hkey_local_machine\software\marksrtz\av" set value_name=datapath /f "usebackq skip=2 tokens=1-3" %%a in (`reg query %key_name% /v %value_name% 2^>nul`) ( set valuename=%%a set valuetype=%%b set valuevalue=%%c ) if defined valuename ( echo data "%valuevalue%" echo name "%valuename%" echo type "%valuetype%" ) else ( echo not found )
the datapath
value set [appdir]\data
on installation, [appdir]
being location user selected.
but said, script output c:\program
if [appdir] set c:\program files (x86)\marksrtz\av\
in installer (which default)
how can fix this?
i note; batch file isn't real program, it's going simple script launches program in correct working directory.
next code snipped should work tokens=1-2*
, setlocal disableextensions
:
rem ensure %valuename% not visible defined already! set "valuename=" /f "usebackq skip=2 tokens=1-2*" %%a in ( `reg query %key_name% /v %value_name% 2^>nul`) ( set "valuename=%%a" set "valuetype=%%b" set "valuevalue=%%c" ) if defined valuename ( echo data "%valuevalue%" echo name "%valuename%" echo type "%valuetype%" ) else ( echo not found )
resources:
Comments
Post a Comment