如何通过 Windows 中的批处理文件在注册表中设置值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17714652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:43:33  来源:igfitidea点击:

How to set value in registry via batch file in Windows?

windowsbatch-fileregistry

提问by CCC

I am going to set a value to windows registry. I want to set variable shitfor StupidMSin registry, but the result is wrong. Following is my code.

我要为 Windows 注册表设置一个值。我想设置的变量shitStupidMS在注册表中,但结果是错误的。以下是我的代码。

set stupidMS=shit
echo %stupidMS% 

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "StupidMS" /t REG_SZ /d ^%stupidMS^%

I think the problem is ^%stupidMS^%, but I quite have no idea how to correct it.

我认为问题是^%stupidMS^%,但我完全不知道如何纠正它。

采纳答案by CCC

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "StupidMS" /t REG_SZ /d "%stupidMS%"