在cmd(bat文件)中运行reg命令? [英] Run reg command in cmd (bat file)?
问题描述
我试图在cmd(bat文件)中运行此reg代码,但无法使其工作。我在哪里做错了?
I'm trying to run this reg code in cmd (bat file) but couldn't make it work. Where am I doing wrong ?
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001
如果我使其为reg文件并双击就可以工作。
it works if I make it reg file and double click.
bat文件代码(这不工作,没有错误)
bat file code (this doesn't work, no errors)
@echo off
reg add "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel" /V HomePage /T REG_DWORD /F /D 1
推荐答案
导入reg文件时,可能会得到一个UAC提示。如果您接受,您拥有更多权利。
You will probably get an UAC prompt when importing the reg file. If you accept that, you have more rights.
由于您正在撰写政策金钥,因此您需要提高权限。
Since you are writing to the 'policies' key, you need to have elevated rights. This part of the registry protected, because it contains settings that are administered by you system administrator.
或者,您可以尝试运行 regedit.exe
Alternatively, you may try to run regedit.exe
from the command prompt.
regedit.exe /S yourfile.reg
..应该静默导入reg文件。有关更多命令行选项,请参见 RegEdit命令行选项语法。
.. should silently import the reg file. See RegEdit Command Line Options Syntax for more command line options.
这篇关于在cmd(bat文件)中运行reg命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!