windows - reg add ignores / f

问题描述 投票:0回答:2

标题说明了一切。

码:

REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\" /f /t REG_DWORD /v "SystemRestore" /d 0 /f

它执行一次时有效,但第二次要求提示。

我找到了这个页面但没有奏效。

Link: https://superuser.com/questions/1198757/reg-add-ignores-f

顺便说一下,我不会上网。生病看看1天。谢谢。

batch-file registry
2个回答
0
投票
REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT" /t REG_DWORD /v "SystemRestore" /d 0 /f

从KeyName中删除尾部反斜杠,因为反斜杠用于在命令行上转义双引号。同时删除可能导致错误的/f的重复参数。

重复使用不会提示测试更改。


0
投票

我在一台机器上遇到同样的问题,其中以下提示甚至用/ f

"reg add "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v "Path" /d "C:\Git\usr\bin;C:\Git\cmd;c:\program files (x86)\common files\oracle\java\javapath;c:\git2\usr\bin;c:\git2\cmd;c:\programs\orant\11.2.0.3.0.x64\bin;c:\programs\orax86\12.1.0.2.0.x86\bin;c:\program files\tibco\tibrv\8.2\bin;c:\programs\orant\11.2.0.3.0\bin;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\program files\microsoft sql server\110\tools\binn" /t REG_EXPAND_SZ /f"

键名没有尾随反斜杠,我也没有看到另一个问题。

答案:解决方案是从值中删除引号,例如/v Path而不是/v "Path"

© www.soinside.com 2019 - 2024. All rights reserved.