注册表中的变量(批处理文件) [英] variable from registry (batch files)
问题描述
我正在为旧游戏模拟人生1制作一个小mod,我想我制作了一个用于安装它的简单批处理文件,只是为了好看. 无论如何,在注册表中,您可以找到安装路径
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 installpath
[HKEY_LOCAL_MACHINE\SOFTWARE\Maxis\The Sims]
"InstallPath"="C:\\Program Files\\Maxis\\The Sims"
现在,我需要将其作为bat文件中的变量,例如
now, i need this to be a variable in my bat file, like
set simsdir=%installpath%
我该怎么做?香港特别行政区谷歌搜索它,但对我来说那是没有意义的,这就是为什么我在这里问:p
how do i do this? ive googled it but it made no sense what so ever to me so, thats why i am asking here :p
欢呼
推荐答案
听起来像您需要致电 reg .exe
在 771240 上接受的答案看起来具有所需的语法.我还没有测试过,但是应该看起来像
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%
编辑
也许可以在一行中全部使用它,这是我可以使它正常工作的唯一方法.我对'ol批处理文件有点生锈
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%
这篇关于注册表中的变量(批处理文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!