variable from registry (batch files)

后端 未结 1 484
一整个雨季
一整个雨季 2021-01-07 15:37

I am making a little mod for the old game sims 1, and i thought i make a simple batch file for installing it, just to be fancy. anyway, in the registry you can find the inst

1条回答
  •  礼貌的吻别
    2021-01-07 16:39

    Sounds like you need to call reg.exe

    The accepted answer on 771240 looks to have the syntax you'll need. I've not tested this, but it should look something like

    Set Reg.Key=HKEY_LOCAL_MACHINE\SOFTWARE\Maxis\The Sims
    Set Reg.Val=InstallPath
    For /F "Tokens=2*" %%A In (
        'Reg Query "%Reg.Key%" /v "%Reg.Val%" ^| Find /I "%Reg.Val%"' )
    Do Call Set simsdir=%%B
    echo %simsdir%
    

    edit

    Maybe try it with the for all on the one line, that's the only way I could get it to work. I'm a bit rusty on the 'ol batch files though

    Set Reg.Key=HKEY_LOCAL_MACHINE\SOFTWARE\Maxis\The Sims
    Set Reg.Val=InstallPath
    
    For /F "Tokens=2*" %%A In ('Reg Query "%Reg.Key%" /v "%Reg.Val%" ^| Find /I "%Reg.Val%"' ) Do Call Set simsdir=%%B
    echo %simsdir%
    

    0 讨论(0)
提交回复
热议问题