[vbs] [ps1] [SCCM] auto configuration of uilanguage
in vbscript:
usage: cscript <script.vbs> /country:france ## or cscript <script.vbs> /country:belgium-french
strComputer = "."
Dim oReg, strKeyPath
dim iRetVal, oWsh, sCmdfr,sCmdus,sCmddelfr
Dim gethomepath, oOsdV4
Dim OSDUserLocale, OSDSystemLocale
Dim OSDInputLocale, OSDUILanguage
Dim OSDGeoID
dim GetTsVariable,result
Dim colNamedArguments
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
Set colNamedArguments = WScript.Arguments.Named
gethomepath=left(WScript.ScriptFullName,len(WScript.ScriptFullName)-len(WScript.ScriptName)-1)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Classes\MIME\Database\Rfc1766"
Set oWsh = CreateObject("WScript.Shell")
On Error Resume Next
Set oOsdV4 = CreateObject("Microsoft.SMS.TSEnvironment")
GetTsVariable = Err.number
On Error GoTo 0
If not GetTsVariable=0 Then
vGeoID = split(InitializeLANGs(),";")(3)
vOSDGeoID = CLng("&H" & vGeoID)
OSDInputLocale = split(InitializeLANGs(),";")(0)
OSDUserLocale = split(InitializeLANGs(),";")(1)
OSDUILanguage = split(InitializeLANGs(),";")(2)
OSDSystemLocale = "en-US"
OSDUILanguageFallback = "en-US"
OSDGeoID = vOSDGeoID
else
OSDUserLocale = oOsdV4("OSDUserLocale")
OSDSystemLocale = oOsdV4("OSDSystemLocale")
OSDInputLocale = oOsdV4("OSDInputLocale")
OSDUILanguage = oOsdV4("OSDUILanguage")
OSDGeoID = oOsdV4("OSDGeoID")
end if
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,split(OSDInputLocale,":")(0),strValue
if isnull(strValue) = true then
strValue = split(InitializeLANGs(),";")(1)
end if
if instr(split(strValue)(0),"-")>0 then
result = split(strValue,";")(0)
else
result = lcase(split(strValue,";")(0)) & "-" & ucase(split(strValue,";")(0))
end if
If GetTsVariable=0 Then
Set ProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
ProgressUI.CloseProgressDialog
end if
sCmd = "cmd /c cscript //nologo " & gethomepath &"\RegionalSettings.wsf /UserLocale:"& OSDUserLocale &" /SystemLocale:en-US /KeyboardLocale:" & chr(34) & OSDInputLocale & ";0409:00000409" & chr(34) & " /UILanguage:" & result & " /GeoID:"& OSDGeoID
iRetVal = oWsh.Run(sCmd, 0, true)
function InitializeLANGs()
Dim ListvariablesLANG, ObjFile, oOption, Line
Set ObjFile = CreateObject("Scripting.FileSystemObject")
ListvariablesLANG = "LangWiz_Initialization.ini"
'Chargement de la liste des LANGs
For Each Line In Split(ObjFile.OpenTextFile(ListvariablesLANG,1).ReadAll(),vbCrLf)
if trim(Line)="" _
or ubound(split(Line,";")) < 1 then
else
if instr(colNamedArguments.Item("country"),"-") > 0 then
argument = split(colNamedArguments.Item("country"),"-")(0) & " (" & split(colNamedArguments.Item("country"),"-")(1) & ")"
else
argument = colNamedArguments.Item("country")
end if
if instr(lcase(split(Line,";")(0)),lcase(trim(argument)))>0 then
InitializeLANGs = split(Line,";")(1) & ";" & split(Line,";")(2) & ";" & split(Line,";")(3) & ";" & split(Line,";")(4)
end if
end if
Next
End function
-----------------------------------------------------------------------------------------------------------------
on the same folder, add this answer file:
LangWiz_Initialization.ini
->
Belgium (French);080c:0000080c;"fr-BE";"fr-FR";15
Canada (French);0c0c:00000c0c;"fr-CA";"fr-FR";27
France (French);040c:0000040c;"fr-FR";"fr-FR";54
Gabon (French);040c:0000040c;"fr-FR";"fr-FR";57
Brazil (English);0416:00000416;"pt-BR";"en-US";20
Canada (English);1009:00001009;"en-CA";"en-US";27
-----------------------------------------------------------------------------------------------------------------
the same in powershell (not tested again):
$ErrorActionPreference = "SilentlyContinue" $HKEY_CURRENT_USER =2147483649 } $strValue = $reg.GetStringValue($HKEY_LOCAL_MACHINE, $strKeyPath, $OSDInputLocale.split(":")(0)) if ($GetTsVariable -eq 0) { $sCmd = "cmd /c cscript //nologo " & $directorypath &"\RegionalSettings.wsf /UserLocale:"& $OSDUserLocale &" /SystemLocale:en-US /KeyboardLocale:" & chr(34) & $OSDInputLocale & ";0409:00000409" & chr(34) & " /UILanguage:" & $result & " /GeoID:"& $OSDGeoID & $sCmd |
and now with or without sccm uilanguage in windows 7 will be configured automatically
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article