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

前端 未结 17 2554
抹茶落季
抹茶落季 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:27

    For Windows 7 (Professional, 64-bit - can't speak for the others) I see that REG no longer spits out

    ! REG.EXE VERSION 3.0
    

    as it does in XP. So the above needs to be modified to use

    skip=2
    

    instead of 4 - which makes things messy if you want your script to be portable. Although it's much more heavyweight and complex, a WMIC based solution may be better.

提交回复
热议问题