1

所以我试图让我的技术人员的生活更轻松,因为他们有时会忘记在新格式化的电脑上设置某些东西。

我设法设置了它的电源设置部分,但我在使用小数符号和日期格式时遇到了问题。我完全导出了 HKEY_USERS.DEFAULT\Control Panel\International,就像我想要的那样,但我无法将它放入当前的 bat 文件中,因为我真的不想让它们运行超过 1 个文件。所以我认为如果可以将注册表值放在批处理文件中并作为单独的外壳启动它可能会很棒?我没有任何建议会很棒。这是我到目前为止所拥有的。

蝙蝠档案:

FOR /F "tokens=3 delims= " %%G IN ('wmic os get Caption /value') DO SET _version=%%G 
echo %_version%

IF %_version%==XP (
POWERCFG /setactive "always on"
POWERCFG /Change "always on" /monitor-timeout-ac 0
POWERCFG /Change "always on" /monitor-timeout-dc 0
POWERCFG /Change "always on" /disk-timeout-ac 0
POWERCFG /Change "always on" /disk-timeout-dc 0
POWERCFG /Change "always on" /standby-timeout-ac 0
POWERCFG /Change "always on" /standby-timeout-dc 0
POWERCFG /Change "always on" /hibernate-timeout-ac 0
POWERCFG /Change "always on" /hibernate-timeout-dc 0
) ELSE (
POWERCFG /Change /monitor-timeout-ac 0
POWERCFG /Change /monitor-timeout-dc 0
POWERCFG /Change /disk-timeout-ac 0
POWERCFG /Change /disk-timeout-dc 0
POWERCFG /Change /standby-timeout-ac 0
POWERCFG /Change /standby-timeout-dc 0
POWERCFG /Change /hibernate-timeout-ac 0
POWERCFG /Change /hibernate-timeout-dc 0
)

pause

我想要在 bat 文件中的注册表值:

[HKEY_USERS\.DEFAULT\Control Panel\International]
"Locale"="00001c09"
"LocaleName"="en-ZA"
"s1159"="AM"
"s2359"="PM"
"sCountry"="South Africa"
"sCurrency"="R"
"sDate"="/"
"sDecimal"="."
"sGrouping"="3;0"
"sLanguage"="ENS"
"sList"="."
"sLongDate"="dd MMMM yyyy"
"sMonDecimalSep"="."
"sMonGrouping"="3;0"
"sMonThousandSep"=" "
"sNativeDigits"="0123456789"
"sNegativeSign"="-"
"sPositiveSign"=""
"sShortDate"="dd/mm/yyyy"
"sThousand"=" "
"sTime"=":"
"sTimeFormat"="hh:mm:ss tt"
"sShortTime"="hh:mm tt"
"sYearMonth"="MMMM yyyy"
"iCalendarType"="1"
"iCountry"="27"
"iCurrDigits"="2"
"iCurrency"="2"
"iDate"="2"
"iDigits"="2"
"NumShape"="1"
"iFirstDayOfWeek"="6"
"iFirstWeekOfYear"="0"
"iLZero"="1"
"iMeasure"="0"
"iNegCurr"="2"
"iNegNumber"="1"
"iPaperSize"="9"
"iTime"="0"
"iTimePrefix"="0"
"iTLZero"="1"
4

2 回答 2

3

如果您在批处理文件中需要它,请尝试以下操作:

@echo off & setlocal
for %%a in (
     "Locale=00001c09"
     "LocaleName=en-ZA"
     "s1159=AM"
     "s2359=PM"
     "sCountry=South Africa"
     "sCurrency=R"
     "sDate=/"
     "sDecimal=."
     "sGrouping=3;0"
     "sLanguage=ENS"
     "sList=."
     "sLongDate=dd MMMM yyyy"
     "sMonDecimalSep=."
     "sMonGrouping=3;0"
     "sMonThousandSep= "
     "sNativeDigits=0123456789"
     "sNegativeSign=-"
     "sPositiveSign="
     "sShortDate=dd/mm/yyyy"
     "sThousand= "
     "sTime=:"
     "sTimeFormat=hh:mm:ss tt"
     "sShortTime=hh:mm tt"
     "sYearMonth=MMMM yyyy"
     "iCalendarType=1"
     "iCountry=27"
     "iCurrDigits=2"
     "iCurrency=2"
     "iDate=2"
     "iDigits=2"
     "NumShape=1"
     "iFirstDayOfWeek=6"
     "iFirstWeekOfYear=0"
     "iLZero=1"
     "iMeasure=0"
     "iNegCurr=2"
     "iNegNumber=1"
     "iPaperSize=9"
     "iTime=0"
     "iTimePrefix=0"
     "iTLZero=1"
     ) do for /f "tokens=1*delims==" %%b in ("%%~a") do (
        REG ADD "HKEY_USERS\.DEFAULT\Control Panel\International" /v "%%~b" /t REG_SZ /d "%%~c" /f
        FOR /f "tokens=2*" %%d IN ('REG QUERY "HKEY_USERS\.DEFAULT\Control Panel\International" /v "%%~b" 2^>nul^| find "REG_SZ"') DO (
            IF NOT "%%~c"=="%%~e" ECHO ERROR reading "%%~e" IN %%b, "%%~c" is NOT SET
        )
    )
)

在写入值后,我添加了控制代码 ( REG QUERY) 以读取注册表。
如果需要,在运行代码之前从注册表中进行备份。

于 2013-08-29T08:44:17.867 回答
1

您可以使用 直接导入.reg文件regedit。只需regedit /S yourfile.reg在您的批处理文件中启动。

/S隐藏确认框。

有关详细信息,请参阅http://www.robvanderwoude.com/regedit.php

于 2013-08-29T08:05:31.230 回答