如何转换多个 .reg 文件以用于单个 .bat 脚本?

如何转换多个 .reg 文件以用于单个 .bat 脚本?

我有三个文件,需要在一个脚本.reg中使用它们:.bat

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000001

Windows Registry Editor Version 5.00

; Originally created at howtogeek.com

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000000

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\International]
"Locale"="00000809"
"LocaleName"="en-GB"
"s1159"="AM"
"s2359"="PM"
"sCountry"="United Kingdom"
"sCurrency"="£"
"sDate"="/"
"sDecimal"="."
"sGrouping"="3;0"
"sLanguage"="ENG"
"sList"=","
"sLongDate"="d MMMM yyyy"
"sMonDecimalSep"="."
"sMonGrouping"="3;0"
"sMonThousandSep"=","
"sNativeDigits"="0123456789"
"sNegativeSign"="-"
"sPositiveSign"=""
"sShortDate"="dd/MM/yyyy"
"sThousand"=","
"sTime"=":"
"sTimeFormat"="HH:mm:ss"
"sShortTime"="HH:mm"
"sYearMonth"="MMMM yyyy"
"iCalendarType"="1"
"iCountry"="44"
"iCurrDigits"="2"
"iCurrency"="0"
"iDate"="1"
"iDigits"="2"
"NumShape"="1"
"iFirstDayOfWeek"="0"
"iFirstWeekOfYear"="0"
"iLZero"="1"
"iMeasure"="0"
"iNegCurr"="1"
"iNegNumber"="1"
"iPaperSize"="9"
"iTime"="1"
"iTimePrefix"="0"
"iTLZero"="1"

[HKEY_CURRENT_USER\Control Panel\International\Geo]
"Nation"="244"

答案1

将所有内容整合到一个注册表文件中:

Windows Registry Editor Version 5.00
    
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000000
    
[HKEY_CURRENT_USER\Control Panel\International] 
"Locale"="00000809"
"LocaleName"="en-GB"
"s1159"="AM"
"s2359"="PM"
"sCountry"="United Kingdom"
"sCurrency"="£"
"sDate"="/"
"sDecimal"="."
"sGrouping"="3;0"
"sLanguage"="ENG"
"sList"=","
"sLongDate"="d MMMM yyyy"
"sMonDecimalSep"="."
"sMonGrouping"="3;0"
"sMonThousandSep"=","
"sNativeDigits"="0123456789"
"sNegativeSign"="-"
"sPositiveSign"=""
"sShortDate"="dd/MM/yyyy"
"sThousand"=","
"sTime"=":"
"sTimeFormat"="HH:mm:ss"
"sShortTime"="HH:mm"
"sYearMonth"="MMMM yyyy"
"iCalendarType"="1"
"iCountry"="44"
"iCurrDigits"="2"
"iCurrency"="0"
"iDate"="1"
"iDigits"="2"
"NumShape"="1"
"iFirstDayOfWeek"="0"
"iFirstWeekOfYear"="0"
"iLZero"="1"
"iMeasure"="0"
"iNegCurr"="1"
"iNegNumber"="1"
"iPaperSize"="9"
"iTime"="1"
"iTimePrefix"="0"
"iTLZero"="1"

[HKEY_CURRENT_USER\Control Panel\International\Geo]
"Nation"="244"

答案2

您可以使用免费 注册转换器 将任何.reg文件转换为 reg 命令 你可以把它放进.bat文件里,

例如,这里介绍如何转换第三个也是最长的文件,并添加管理员权限测试(reg命令所需)。

您可以对另外两个较小的文件执行相同操作,并将其 reg命令添加到此文件中:

@Echo Off
Title Reg Converter v1.2 & Color 1A
cd %systemroot%\system32
call :IsAdmin

Reg.exe add "HKCU\Control Panel\International" /v "Locale" /t REG_SZ /d "00000809" /f
Reg.exe add "HKCU\Control Panel\International" /v "LocaleName" /t REG_SZ /d "en-GB" /f
Reg.exe add "HKCU\Control Panel\International" /v "s1159" /t REG_SZ /d "AM" /f
Reg.exe add "HKCU\Control Panel\International" /v "s2359" /t REG_SZ /d "PM" /f
Reg.exe add "HKCU\Control Panel\International" /v "sCountry" /t REG_SZ /d "United Kingdom" /f
Reg.exe add "HKCU\Control Panel\International" /v "sCurrency" /t REG_SZ /d "£" /f
Reg.exe add "HKCU\Control Panel\International" /v "sDate" /t REG_SZ /d "/" /f
Reg.exe add "HKCU\Control Panel\International" /v "sDecimal" /t REG_SZ /d "." /f
Reg.exe add "HKCU\Control Panel\International" /v "sGrouping" /t REG_SZ /d "3;0" /f
Reg.exe add "HKCU\Control Panel\International" /v "sLanguage" /t REG_SZ /d "ENG" /f
Reg.exe add "HKCU\Control Panel\International" /v "sList" /t REG_SZ /d "," /f
Reg.exe add "HKCU\Control Panel\International" /v "sLongDate" /t REG_SZ /d "d MMMM yyyy" /f
Reg.exe add "HKCU\Control Panel\International" /v "sMonDecimalSep" /t REG_SZ /d "." /f
Reg.exe add "HKCU\Control Panel\International" /v "sMonGrouping" /t REG_SZ /d "3;0" /f
Reg.exe add "HKCU\Control Panel\International" /v "sMonThousandSep" /t REG_SZ /d "," /f
Reg.exe add "HKCU\Control Panel\International" /v "sNativeDigits" /t REG_SZ /d "0123456789" /f
Reg.exe add "HKCU\Control Panel\International" /v "sNegativeSign" /t REG_SZ /d "-" /f
Reg.exe add "HKCU\Control Panel\International" /v "sPositiveSign" /t REG_SZ /d "" /f
Reg.exe add "HKCU\Control Panel\International" /v "sShortDate" /t REG_SZ /d "dd/MM/yyyy" /f
Reg.exe add "HKCU\Control Panel\International" /v "sThousand" /t REG_SZ /d "," /f
Reg.exe add "HKCU\Control Panel\International" /v "sTime" /t REG_SZ /d ":" /f
Reg.exe add "HKCU\Control Panel\International" /v "sTimeFormat" /t REG_SZ /d "HH:mm:ss" /f
Reg.exe add "HKCU\Control Panel\International" /v "sShortTime" /t REG_SZ /d "HH:mm" /f
Reg.exe add "HKCU\Control Panel\International" /v "sYearMonth" /t REG_SZ /d "MMMM yyyy" /f
Reg.exe add "HKCU\Control Panel\International" /v "iCalendarType" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International" /v "iCountry" /t REG_SZ /d "44" /f
Reg.exe add "HKCU\Control Panel\International" /v "iCurrDigits" /t REG_SZ /d "2" /f
Reg.exe add "HKCU\Control Panel\International" /v "iCurrency" /t REG_SZ /d "0" /f
Reg.exe add "HKCU\Control Panel\International" /v "iDate" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International" /v "iDigits" /t REG_SZ /d "2" /f
Reg.exe add "HKCU\Control Panel\International" /v "NumShape" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International" /v "iFirstDayOfWeek" /t REG_SZ /d "0" /f
Reg.exe add "HKCU\Control Panel\International" /v "iFirstWeekOfYear" /t REG_SZ /d "0" /f
Reg.exe add "HKCU\Control Panel\International" /v "iLZero" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International" /v "iMeasure" /t REG_SZ /d "0" /f
Reg.exe add "HKCU\Control Panel\International" /v "iNegCurr" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International" /v "iNegNumber" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International" /v "iPaperSize" /t REG_SZ /d "9" /f
Reg.exe add "HKCU\Control Panel\International" /v "iTime" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International" /v "iTimePrefix" /t REG_SZ /d "0" /f
Reg.exe add "HKCU\Control Panel\International" /v "iTLZero" /t REG_SZ /d "1" /f
Reg.exe add "HKCU\Control Panel\International\Geo" /v "Nation" /t REG_SZ /d "244" /f
Exit

:IsAdmin
Reg.exe query "HKU\S-1-5-19\Environment"
If Not %ERRORLEVEL% EQU 0 (
  Cls & Echo You must have administrator rights to continue ... 
  Pause & Exit
)
Cls
goto:eof

答案3

对于统一文件中的一个或多个注册表项,请尝试以下操作杂交种 file.cmd+ file.reg

  • 另存为file.bat/file.cmd并以管理员身份运行:
    Windows Registry Editor Version 5.00
    
    ;@(cls & %__APPDIR__%reg.exe import "%~f0" >nul 2>nul & goto :EOF)
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
    "EnableLUA"=dword:00000001
    
    [HKEY_CURRENT_USER\Control Panel\International]
    "Locale"="00000809"
    "LocaleName"="en-GB"
    "s1159"="AM"
    "s2359"="PM"
    "sCountry"="United Kingdom"
    "sCurrency"="£"
    "sDate"="/"
    "sDecimal"="."
    "sGrouping"="3;0"
    "sLanguage"="ENG"
    "sList"=","
    "sLongDate"="d MMMM yyyy"
    "sMonDecimalSep"="."
    "sMonGrouping"="3;0"
    "sMonThousandSep"=","
    "sNativeDigits"="0123456789"
    "sNegativeSign"="-"
    "sPositiveSign"=""
    "sShortDate"="dd/MM/yyyy"
    "sThousand"=","
    "sTime"=":"
    "sTimeFormat"="HH:mm:ss"
    "sShortTime"="HH:mm"
    "sYearMonth"="MMMM yyyy"
    "iCalendarType"="1"
    "iCountry"="44"
    "iCurrDigits"="2"
    "iCurrency"="0"
    "iDate"="1"
    "iDigits"="2"
    "NumShape"="1"
    "iFirstDayOfWeek"="0"
    "iFirstWeekOfYear"="0"
    "iLZero"="1"
    "iMeasure"="0"
    "iNegCurr"="1"
    "iNegNumber"="1"
    "iPaperSize"="9"
    "iTime"="1"
    "iTimePrefix"="0"
    "iTLZero"="1"
    
    [HKEY_CURRENT_USER\Control Panel\International\Geo]
    "Nation"="244"
    

观察1.只会使用一个值;添加一个值时,另一个值将覆盖第一个值,因此在同一个注册表中只能使用其中一个,不能同时使用两个值:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000001

; // use one or the other not both  // ;

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000000

观察:2。您也可以将其另存为file.reg,以 开头的行将;被视为注释,导入替换%__APPDIR__%reg.exe import "%~f0"%__APPDIR__%reg.exe import "file.reg"

相关内容