是否可以通过.bat/.cmd脚本修改注册表项?

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

是否可以通过 .bat/.cmd 脚本修改注册表值(无论是字符串还是 DWORD)?

windows batch-file cmd automation registry
9个回答
115
投票

@Franci Penov - 可以用 /f 来修改 is,例如


reg add "HKCU\Software\etc\etc" /f /v "value" /t REG_SZ /d "Yes"



42
投票
http://www.ss64.com/nt/reg.html

Syntax: REG QUERY [ROOT\]RegKey /v ValueName [/s] REG QUERY [ROOT\]RegKey /ve --This returns the (default) value REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f] REG ADD [ROOT\]RegKey /ve [/d Data] [/f] -- Set the (default) value REG DELETE [ROOT\]RegKey /v ValueName [/f] REG DELETE [ROOT\]RegKey /ve [/f] -- Remove the (default) value REG DELETE [ROOT\]RegKey /va [/f] -- Delete all values under this key REG COPY [\\SourceMachine\][ROOT\]RegKey [\\DestMachine\][ROOT\]RegKey REG EXPORT [ROOT\]RegKey FileName.reg REG IMPORT FileName.reg REG SAVE [ROOT\]RegKey FileName.hiv REG RESTORE \\MachineName\[ROOT]\KeyName FileName.hiv REG LOAD FileName KeyName REG UNLOAD KeyName REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/v ValueName] [Output] [/s] REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/ve] [Output] [/s] Key: ROOT : HKLM = HKey_Local_machine (default) HKCU = HKey_current_user HKU = HKey_users HKCR = HKey_classes_root ValueName : The value, under the selected RegKey, to edit. (default is all keys and values) /d Data : The actual data to store as a "String", integer etc /f : Force an update without prompting "Value exists, overwrite Y/N" \\Machine : Name of remote machine - omitting defaults to current machine. Only HKLM and HKU are available on remote machines. FileName : The filename to save or restore a registry hive. KeyName : A key name to load a hive file into. (Creating a new key) /S : Query all subkeys and values. /S Separator : Character to use as the separator in REG_MULTI_SZ values the default is "\0" /t DataType : REG_SZ (default) | REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ Output : /od (only differences) /os (only matches) /oa (all) /on (no output)



27
投票
reg

命令编写脚本。 示例:


reg add HKCU\Software\SomeProduct reg add HKCU\Software\SomeProduct /v Version /t REG_SZ /d v2.4.6

这将创建密钥 
HKEY_CURRENT_USER\Software\SomeProduct

,并向该密钥添加一个名为“Version”的字符串值“v2.4.6”。


reg /?

有详细信息。

    


15
投票

reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\etc\etc /v Valuename /t REG_SZ /d valuedata /f

下面是一个将 Internet Explorer 设置为默认浏览器的真实示例

reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice /v ProgId /t REG_SZ /d IE.HTTPS /f

  
/f Force:强制更新,不提示“值存在,覆盖 是/否”

/d Data :要存储为“字符串”、整数等的实际数据

/v Value : 值名称,例如 ProgId

/t 数据类型:REG_SZ(默认)| REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ

了解有关读取、设置或删除注册表项和值以及从 .REG 文件保存和恢复的更多信息。从
这里


5
投票

此处格式:

http://support.microsoft.com/kb/310516

这可以在任何 Windows 机器上运行,无需安装其他软件。


2
投票


2
投票


0
投票
https://www.sordum.org/8478/reg-converter-v1-2/


-2
投票
http://www.chaminade.org/MIS/Articles/RegistryEdit.htm

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