use*_*989 47 windows registry cmd batch-file
我正在尝试在cmd(bat文件)中运行此reg代码,但我无法使其工作.我哪里做错了?
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel]
"HomePage"=dword:00000001
Run Code Online (Sandbox Code Playgroud)
如果我将它作为一个reg文件并双击,它就可以工作.
Bat文件代码(这不起作用,没有错误):
@echo off
reg add "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel" /V HomePage /T REG_DWORD /F /D 1
Run Code Online (Sandbox Code Playgroud)
Gol*_*rol 62
导入reg文件时,您可能会收到UAC提示.如果您接受,那么您拥有更多权利.
由于您要写入"政策"密钥,因此您需要拥有提升的权限.此部分注册表受到保护,因为它包含由系统管理员管理的设置.
或者,您可以尝试regedit.exe
从命令提示符运行.
regedit.exe /S yourfile.reg
Run Code Online (Sandbox Code Playgroud)
..应该默默导入reg文件.有关更多命令行选项,请参阅RegEdit命令行选项语法.
Noa*_*nos 48
在命令行中,最好使用REG工具而不是REGEDIT:
REG IMPORT yourfile.reg
Run Code Online (Sandbox Code Playgroud)
REG专为控制台模式而设计,而REGEDIT则用于图形模式.这就是为什么运行regedit.exe/S yourfile.reg是一个坏主意,因为如果有错误你将不会收到通知,而REG工具将提示:
> REG IMPORT missing_file.reg
ERROR: Error opening the file. There may be a disk or file system error.
> %windir%\System32\reg.exe /?
REG Operation [Parameter List]
Operation [ QUERY | ADD | DELETE | COPY |
SAVE | LOAD | UNLOAD | RESTORE |
COMPARE | EXPORT | IMPORT | FLAGS ]
Return Code: (Except for REG COMPARE)
0 - Successful
1 - Failed
For help on a specific operation type:
REG Operation /?
Examples:
REG QUERY /?
REG ADD /?
REG DELETE /?
REG COPY /?
REG SAVE /?
REG RESTORE /?
REG LOAD /?
REG UNLOAD /?
REG COMPARE /?
REG EXPORT /?
REG IMPORT /?
REG FLAGS /?
Run Code Online (Sandbox Code Playgroud)
如果内存服务正确,则该reg add
命令将不会创建整个目录路径(如果它不存在).这意味着如果任何父注册表项不存在,则必须逐个手动创建它们.我知道这真烦人! 例:
@echo off
reg add "HKCU\Software\Policies"
reg add "HKCU\Software\Policies\Microsoft"
reg add "HKCU\Software\Policies\Microsoft\Internet Explorer"
reg add "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel"
reg add "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel" /v HomePage /t REG_DWORD /d 1 /f
pause
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
254030 次 |
最近记录: |