【问题标题】:Running a windows reg add command in non-interactive mode在非交互模式下运行 windows reg add 命令
【发布时间】:2023-03-17 21:53:01
【问题描述】:

我正在尝试编写一个小批量脚本来更改一些注册表项。

现在要从命令行执行此操作,可以使用reg add 命令。当指定的注册表项已经存在时,它会要求覆盖该值。

例如reg add "HKCU\Control Panel\Colors" /v Background /t REG_SZ /d "120 0 0" 产生Value Background exists, overwrite(Yes/No)? 并且只有当我按下y 时命令才会完成。

从批处理脚本发出命令时也是如此。由于我希望该过程自动化并且不需要进一步的用户输入,因此我想删除确认请求。那么是否可以非交互方式运行此命令?

【问题讨论】:

  • 打开命令提示符窗口,输入Reg Add /?,然后按回车键。输出清楚地显示/F 和描述Force overwriting the existing registry entry without prompt。鉴于此,我建议您将命令更改为 @"%__AppDir__%reg.exe" Add "HKCU\Control Panel\Colors" /V Background /D "120 0 0" /F > NUL> NUL 是隐藏任何打印到控制台的“成功”消息).
  • 非常感谢,这解决了我的问题

标签: windows batch-file registry non-interactive


【解决方案1】:

您可以使用 Compo 在 cmets 中提到的 /F 标志,也可以使用 .reg 文件并以静默模式启动它:

start regedit /s "C:\path\to\regfile.reg"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-14
    • 2017-02-05
    • 2021-09-15
    • 1970-01-01
    • 2015-02-19
    • 2022-06-30
    • 1970-01-01
    • 2014-02-13
    相关资源
    最近更新 更多