2013-08-29 124 views
1

所以即時通訊設法讓我的技術人員的生活更輕鬆,因爲他們有時會忘記在新格式化的電腦上設置某些內容。在.bat文件中啓動.reg文件

我設法設置了它的功率設置部分,但即時通訊有麻煩的小數點符號和日期格式。我有一個HKEY_USERS.DEFAULT \ Control Panel \ International的完全導出,就像我想要的一樣,但我很難將它放入當前的bat文件,因爲我不真的想讓它們運行超過1個文件。所以我認爲它可能會很好,如果可以把註冊表值放在批處理文件中,也許可以啓動它作爲一個單獨的shell?我dono任何意見將是偉大的。這是我到目前爲止。

.bat文件:

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 

註冊表值我要在批處理文件:

[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"="" 
"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" 

回答

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=" 
    "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 
     ) 
    ) 
) 

我加入conrol代碼(REG QUERY)讀取註冊表後寫的值。
運行代碼之前,如果需要從註冊表進行備份。

+0

似乎並沒有改變註冊表中的值。即使以管理員身份運行, –

+0

也可以在XP和win8上運行。 – Endoro

+0

@ user2728293我添加了控制代碼以在寫入新值後讀取註冊表。如果該值未設置,則會收到錯誤消息。請現在試試。 – Endoro