How can I get the value of a registry key from within a batch script?

前端 未结 17 2608
抹茶落季
抹茶落季 2020-11-27 15:12

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 (\         


        
17条回答
  •  悲哀的现实
    2020-11-27 15:15

    This work for me with variable that contains spaces on Windows 7:

    FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKEY_LOCAL_MACHINE\Software\SomeAPP" /v ValueName`) DO (
        set appdir=%%A %%B
        )
    ECHO %appdir%
    

    Variable A contains all data before first space, B - rest part of ValueName (including further spaces), so appdir = ValueName

提交回复
热议问题