The Problem
A load of PCs at my work have strangely been showing as having different regional formats even though the languages were set correctly. This was annoying as one of our in-house apps uses .Net date-time parsing which fails when the formats aren't correct. Instead of running up to each PC and manually clicking through forms, I wanted a scripted way (any would do, of forcing all related language settings on all versions of Windows (7 and up).
The Process
I made a batch script. Quick and cheezy.
Using control intl.cpl,,f:<filepath .xml="">you can make windows apply an XML file template. https://support.microsoft.com/en-gb/kb/2764405
I don't want to carry an XML file with the batch file... It just... Annoys me... Also, some of the settings require admin rights to take effect. So, one batch function for creating a temp XML file to be deleted after use and one function to check for admin rights.
The Code
@echo off
call:IsAdmin
set XMLPath="%~dp0en-GB.xml"
if exist %XMLPath% ( del /F /Q %XMLPath% )
call:CreateLocaleXML %XMLPath%
control intl.cpl,,/f:%XMLPath%
del /F /Q %XMLPath%
pause & exit
:CreateLocaleXML
echo ^<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend"^> >> %1
echo ^<!-- user list --^> >> %1
echo ^<gs:UserList^> >> %1
echo ^<gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/^> >> %1
echo ^</gs:UserList^> >> %1
echo ^<gs:MUILanguagePreferences^> >> %1
echo ^<gs:MUILanguage Value="en-GB"/^> >> %1
echo ^<gs:MUIFallback Value="en-GB"/^> >> %1
echo ^</gs:MUILanguagePreferences^> >> %1
echo ^<!-- system locale --^> >> %1
echo ^<gs:SystemLocale Name="en-GB"/^> >> %1
echo ^<!-- input preferences --^> >> %1
echo ^<gs:InputPreferences^> >> %1
echo ^<gs:InputLanguageID Action="add" ID="0809:00000809"/^> >> %1
echo ^<gs:InputLanguageID Action="remove" ID="0409:00000409"/^> >> %1
echo ^</gs:InputPreferences^> >> %1
echo ^<!-- user locale --^> >> %1
echo ^<gs:UserLocale^> >> %1
echo ^<gs:Locale Name="en-GB" SetAsCurrent="true" ResetAllSettings="true"^> >> %1
echo ^</gs:Locale^> >> %1
echo ^</gs:UserLocale^> >> %1
echo ^</gs:GlobalizationServices^> >> %1
goto:eof
:IsAdmin
"%systemroot%\system32\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
Notes
In the batch function to create the XML file, I use the echo command and redirect the output to a file, but the '<' and '>' characters from XML are interpreted by the command processor as redirections. So I used the '^' character escape symbol.
I'm not sure if this works yet... Should do though.