Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

language settings change

21 views
Skip to first unread message

Benji

unread,
Apr 29, 2005, 2:46:08 PM4/29/05
to
I need to change the language settings on multiple computers can someone
point me to a sample that changes the language settings?

ie uses a WMI to connect and change the setting

Thanks
xp pro


Corné Bogaarts

unread,
May 1, 2005, 3:58:17 PM5/1/05
to
I made some scripts that perform these actions on Windows2003, they
may need a little change to work on WinXP.
There are now 2 scripts:
- one for reading the settings from a computer that has the correct
language, currency, etc.
- another for setting these values on another computer.

The first script writes the names and values of the registrykeys to a
txt-file (separated by Tabs). You will have to open this txt-file and
copy the values to the 'FillCorrectsettings' Sub-routine in the second
script. (Currently the settings in the 2nd-script are for
Dutch/Nederland, which is most probably not what you want/need.)

I will post each script in a separate posting.


CU,

Corné

Corné Bogaarts

unread,
May 1, 2005, 4:04:09 PM5/1/05
to
First script: ReadRegionalSettings.vbs
(Some of the lines are too long, sorry)

'********************************************************************
'* Goal
'* This script reads the Regional Settings as they're in the Registry.
'* It writes them to a logfile in a format that is easily used in the
'* SetRegionalSettings-script.
'*
'********************************************************************
'* Prerequisites
'* Run the script with administrative privileges
'*
'********************************************************************
'* Changes
'* Version Name Date Comment
'* v.1.0 Corné Bogaarts 281204 Basic functionality works
'* v.1.1 Corné Bogaarts 010505 Translated to English
'*
'*
'********************************************************************

Option Explicit
'On Error Resume Next

Dim strComputer, strKeyPath, strEntryName, strValue, strLogFile

Dim objReg, objFSO, objLogFile

Dim arrValue, byteValue, arrEntryNames, arrValueTypes, i

Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_USER = &H80000001
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7

strKeyPath = ".DEFAULT\Control Panel\International"
strLogFile = "D:\RegionalSettings.txt"

'*** If Scripthost is not CScript (i.e. is WScript), then put message on
screen and end script
If NOT Right(CStr(LCase(WScript.FullName)), 11) = "cscript.exe" Then
UseCScript

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.CreateTextFile (strLogFile)
'objLogFile.Writeline ("This logfile was made on " & Date & " at " & Time &
"." & VbCrLf )

strComputer = "."
'Set objArgs = Wscript.Arguments
'strComputer = objArgs(0)

' Connect to the WMI Regisitry-provider
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

objReg.EnumValues HKEY_USERS,strKeyPath,arrEntryNames,arrValueTypes
For Each strEntryName In arrEntryNames
'*** This is the only Binary value
If strEntryName = "DefaultBlindDialFlag" Then
objReg.GetBinaryValue HKEY_USERS,strKeyPath,
strEntryName,arrValue
For Each byteValue in arrValue
WScript.Echo strEntryName & " = " & byteValue
objLogFile.Writeline (strEntryName & vbTab &
byteValue)
Next
Else
'*** These are all RegSZ value's
objReg.GetStringValue
HKEY_USERS,strKeyPath,strEntryName,strValue
Wscript.Echo strEntryName & " = " & strValue
objLogFile.Writeline (strEntryName & vbTab & strValue)
End If
Next
'*** This is the only value that's in a sub-key
strEntryName = "Nation"
objReg.GetStringValue HKEY_USERS,strKeyPath &
"\Geo",strEntryName,strValue
Wscript.Echo strEntryName & " = " & strValue
objLogFile.Writeline ( strEntryName & vbTab & strValue )

'*************************************************
'* Sub-routines
'*************************************************
Sub UseCScript
'* Message n screen and stop script-execution
WScript.Echo "This script should be started with 'CScript', otherwise
you'd have " & vbCrLf & _
"to click [OK] very often." & vbCrLf & "Usage:" & vbCrLf & _
"cscript " & WScript.ScriptName & "<Enter>"
WScript.Quit
End Sub


On Fri, 29 Apr 2005 11:46:08 -0700, "Benji" <g...@radiant.net> wrote:

Corné Bogaarts

unread,
May 1, 2005, 4:01:38 PM5/1/05
to
The first script: ReadRegionalsettings.vbs
(Apologies for using some lines that are too long)

'********************************************************************
'* Goal
'* This script changes the Regional Settings in the Registry of a Win2K3
Server
'*
'* The script checks some things: is the server reachable, is the OS Win2K3,
'* are the Regional Settings correct (i.e. equal to the values in the script.)


'*
'********************************************************************
'* Prerequisites
'* Run the script with administrative privileges
'*
'********************************************************************
'* Changes
'* Version Name Date Comment

'* v.1.0 Corné Bogaarts 291204 Basic functionality works
'* v.1.1 Corné Bogaarts 210305 Made script less fragile by taking up
'* the settings in the script, instead of as
'* a separate textfile.
'* v.1.2 Corné Bogaarts 010505 Translated to English
'*
'* TODO: Have the script make the same changes to Current_User
'*
'********************************************************************

Option Explicit
'On Error Resume Next

Dim strLanguage, strNextLine, strKeyPath, strComputer, strItem
Dim strCollectionName, strEntryName, strValue, strSetting

Dim objCorrectSettings, objFSO, objSettingsFile, objReg, objWMIService
Dim objOperatingSystem, objCurrentSettings

Dim arrSetting, colOperatingSystems, arrEntryNames, arrValueTypes, arrValue
Dim byteValue, arrItem, blCompare

'*** Some constants for registry-editting


Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_USER = &H80000001
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7

'*** A constant for reading a file
Const ForReading = 1

'* Registry-path (in HK_Users) for Default-user


strKeyPath = ".DEFAULT\Control Panel\International"

strComputer = "."

'*** Make 2 dictionaries and set the 'compare-mode' (necessary
'*** for the comparison that we're going to make). The compare-
'*** mode must be set before any data is entered into the dic-
'*** tionary.
Set objCurrentSettings= CreateObject("Scripting.Dictionary")
objCurrentSettings.CompareMode = vbBinaryCompare
Set objCorrectSettings = CreateObject("Scripting.Dictionary")
objCorrectSettings.CompareMode = vbBinaryCompare
FillCorrectSettings
'PrintCollectionContents objCorrectSettings

Set objFSO = CreateObject("Scripting.FileSystemObject")

'*** Connect to WMI (de CIMV2 namespace), necessary for most WMI-actions
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
'*** Connect to the WMI Registry-provider, necessary for working with the
Registry


Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

'* Verify the OS-version. If not Win2K3, than stop the script.
'*** Win2K = 5.0, WinXP = 5.1, Win2K3 = 5.2
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from
Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
' Wscript.Echo strComputer & vbTab & objOperatingSystem.Caption & vbTab & _
' objOperatingSystem.Version
If Left(objOperatingSystem.Version, 3) <> "5.2" Then
OsNotWin2K3
End If
Next

'* Verify if the Regional Settings are 'Nederlands'
'*** Check all settings, if 1 or more is not correct, then change all settings
ReadSettings strKeyPath, arrEntryNames
'*** To check the script, write the collection to the screen:
'PrintCollectionContents objCurrentSettings

'*** Compare the current with the correct settings:
blCompare = CompareSettings (objCorrectSettings, objCurrentSettings)
If blCompare = True Then
'*** all items are the same, so nothing has to be changed
WScript.Echo "All settings are already correct."
Else
'*** 1 or more items not the same, so make he changes
SetCorrectSettings
WriteEndMessage
End If

'*************************************************
'* Sub-routines
'*************************************************
Sub OsNotWin2K3
'* If the OS si not Win2003, then write a message to the screen and stop the
script.
WScript.Echo "The Operating System on this server is not Windows
Server 2003." & vbCrLf & _
"The script-execution will be stopped."
WScript.Quit
End Sub

Sub FillCorrectSettings
'* Fill the Dictionary with the correct settings
'*** You can copy these settings from the logfile that was
'*** written by the 'ReadRegionalSettings'-script.
objCorrectSettings.Add "iCountry", "31"
objCorrectSettings.Add "iCurrDigits", "2"
objCorrectSettings.Add "iCurrency", "2"
objCorrectSettings.Add "iDate", "1"
objCorrectSettings.Add "iDigits", "2"
objCorrectSettings.Add "iLZero", "1"
objCorrectSettings.Add "iMeasure", "0"
objCorrectSettings.Add "iNegCurr", "11"
objCorrectSettings.Add "iTime", "1"
objCorrectSettings.Add "iTLZero", "0"
objCorrectSettings.Add "Locale", "00000413"
objCorrectSettings.Add "s1159", ""
objCorrectSettings.Add "s2359", ""
objCorrectSettings.Add "sCountry", "Netherlands"
objCorrectSettings.Add "sCurrency", "€"
objCorrectSettings.Add "sDate", "-"
objCorrectSettings.Add "sDecimal", ","
objCorrectSettings.Add "sLanguage", "NLD"
objCorrectSettings.Add "sList", ";"
objCorrectSettings.Add "sLongDate", "dddd d MMMM yyyy"
objCorrectSettings.Add "sShortDate", "d-M-yyyy"
objCorrectSettings.Add "sThousand", "."
objCorrectSettings.Add "sTime", ":"
objCorrectSettings.Add "DefaultBlindDialFlag", "0"
objCorrectSettings.Add "sTimeFormat", "H:mm:ss"
objCorrectSettings.Add "iTimePrefix", "0"
objCorrectSettings.Add "sMonDecimalSep", ","
objCorrectSettings.Add "sMonThousandSep", "."
objCorrectSettings.Add "iNegNumber", "1"
objCorrectSettings.Add "sNativeDigits", "0123456789"
objCorrectSettings.Add "NumShape", "1"
objCorrectSettings.Add "iCalendarType", "1"
objCorrectSettings.Add "iFirstDayOfWeek", "0"
objCorrectSettings.Add "iFirstWeekOfYear", "2"
objCorrectSettings.Add "sGrouping", "3;0"
objCorrectSettings.Add "sMonGrouping", "3;0"
objCorrectSettings.Add "sPositiveSign", ""
objCorrectSettings.Add "sNegativeSign", "-"
objCorrectSettings.Add "Nation", "176"
End Sub

Sub ReadSettings (strKeyPath,arrEntryNames)
'* Read RegionalSettings from Registry and put them in a Dictionary


objReg.EnumValues HKEY_USERS,strKeyPath,arrEntryNames,arrValueTypes
For Each strEntryName In arrEntryNames
'*** This is the only Binary value
If strEntryName = "DefaultBlindDialFlag" Then
objReg.GetBinaryValue HKEY_USERS,strKeyPath,
strEntryName,arrValue
For Each byteValue in arrValue

objCurrentSettings.Add strEntryName, byteValue


Next
Else
'*** These are all RegSZ value's
objReg.GetStringValue
HKEY_USERS,strKeyPath,strEntryName,strValue

objCurrentSettings.Add strEntryName, strValue


End If
Next
'*** This is the only value that's in a sub-key
strEntryName = "Nation"
objReg.GetStringValue HKEY_USERS,strKeyPath &
"\Geo",strEntryName,strValue

objCurrentSettings.Add strEntryName, strValue
End Sub

Sub PrintCollectionContents (strCollectionName)
'* Write the contents of a collection to the screen
'* Usefull for checking the script
WScript.Echo "Subroutine 'PrintCollectionContents'"
For Each strItem In strCollectionName
' WScript.Echo strItem & " = " & objDictionary.Item(strItem)
If strItem = "DefaultBlindDialFlag" Then
arrValue = Array(strCollectionName.Item(strItem))


For Each byteValue in arrValue

WScript.Echo strItem & " = " & byteValue
Next
ElseIf strItem = "Nation" Then
WScript.Echo strItem & " = " &
strCollectionName.Item(strItem)
Else
WScript.Echo strItem & " = " &
strCollectionName.Item(strItem)
End If
Next
WScript.Echo "End of subroutine 'PrintCollectionContents'"
End Sub

Function CompareSettings (objCorrectSettings, objCurrentSettings)
'* Compare the contents of both collections
'* If at least one item is not the same, then return-value = False
'* otherwise it's True.
'*** Rem: The value of 'DefaultBlindDialFlag' is not compared: technically
more dificult as
'*** they're arrays, and the values don't seem important.
'*** --> can be added later
' WScript.Echo "Function CompareSettings"
CompareSettings = True
'*** Verify if all items of A are in B
For Each strSetting In objCorrectSettings
If NOT objCurrentSettings.Exists(strSetting) Then
' WScript.Echo vbTab & strSetting & " doesn't exist"
CompareSettings = False
Else 'if so, are the values the same?
If strSetting <> "DefaultBlindDialFlag" Then
If objCurrentSettings.Item(strSetting) <>
objCorrectSettings.Item(strSetting) Then
' WScript.Echo vbTab & strSetting & "
not equal in both Dictionaries:" & _
'
objCorrectSettings.Item(strSetting) & " and " &
objCurrentSettings.Item(strSetting)
CompareSettings = False
End If
End If
End If
Next
'*** Verify if all items of B are in A
For Each strSetting In objCurrentSettings
If NOT objCorrectSettings.Exists(strSetting) Then
' WScript.Echo vbTab & strSetting & " doesn't exist"
CompareSettings = False
Else 'if so, are the values the same?
If strSetting <> "DefaultBlindDialFlag" Then
If objCorrectSettings.Item(strSetting) <>
objCurrentSettings.Item(strSetting) Then
' WScript.Echo vbTab & strSetting & "
not equal in bothDictionaries:" & _
'
objCorrectSettings.Item(strSetting) & " and " &
objCurrentSettings.Item(strSetting)
CompareSettings = False
End If
End If
End If
Next
' WScript.Echo "CompareSettings = " & CompareSettings & "."
' WScript.Echo "End of Function CompareSettings"
If CompareSettings = False Then WScript.Echo "Teh settings in the
Registry are not correct" & _
" and will be adjusted."
End Function

Sub SetCorrectSettings
'* Wite the correct settings to the Registry
' WScript.Echo "Subroutine SetCorrectSettings"
For Each strItem In objCorrectSettings
' WScript.Echo strItem & " = " & objDictionary.Item(strItem)
If strItem = "DefaultBlindDialFlag" Then
' WScript.Echo "Reg_Binary"
arrItem = Array(objCorrectSettings.Item(strItem))
RegEditBinary strKeyPath, strItem, arrItem
ElseIf strItem = "Nation" Then
' WScript.Echo "\Geo - Nation"
RegEditSZ strKeyPath & "\Geo", strItem,
objCorrectSettings.Item(strItem)
Else
' WScript.Echo "Reg_SZ"
RegEditSZ strKeyPath, strItem,
objCorrectSettings.Item(strItem)
End If
Next
WScript.Echo "Regional Settings adjusted."
' WScript.Echo "End of subroutine SetCorrectSettings"
End Sub

Sub RegEditSZ (strKeyPath, strEntryName, strValue)
'* Changing String-valued (REG_SZ) Entries
objReg.SetStringValue HKEY_USERS, strKeyPath, strEntryName, strValue
End Sub

Sub RegEditBinary (strKeyPath, strEntryName, arrValue)
'* Changing Binary-valued (REG_Binary) Entries
'*** SetBinaryValue needs an Array as 'value', even if there's only 1 value in
it
objReg.SetBinaryValue HKEY_USERS, strKeyPath, strEntryName, arrValue
End Sub

Sub WriteEndMessage
'* Message on screen when script is finished.
WScript.Echo "Regional Settings adjusted." & vbCrLf & vbCrLf &
"REMEMBER:" & vbCrLf & _
"The server needs to be restarted, before the new
settings are activated."
End Sub

On Fri, 29 Apr 2005 11:46:08 -0700, "Benji" <g...@radiant.net> wrote:

Corné Bogaarts

unread,
May 1, 2005, 4:13:15 PM5/1/05
to
My mistake, this is of course the second script: SetRegionalSettings.vbs

You can add some lines of code to make it work on more than one computer:
simply have a loop fill the strComputer-variable with the computer-names.


On Sun, 01 May 2005 22:01:38 +0200, Corné Bogaarts
<does.no...@somewhere.com> wrote:

>The first script: ReadRegionalsettings.vbs
>(Apologies for using some lines that are too long)
>
>'********************************************************************
>'* Goal
>'* This script changes the Regional Settings in the Registry of a Win2K3
>Server
>'*
>'* The script checks some things: is the server reachable, is the OS Win2K3,
>'* are the Regional Settings correct (i.e. equal to the values in the script.)
>'*

<snip>

Benji

unread,
May 2, 2005, 11:28:17 AM5/2/05
to
Great,

Thanks its perfect
"Corné Bogaarts" <does.no...@somewhere.com> wrote in message
news:eeda71hvvl2hp7ps2...@4ax.com...

Benji

unread,
May 2, 2005, 1:27:46 PM5/2/05
to
Corne,

I just want to change my networked computers to Canada English from Us
english. So infact I only want to remotely connect and change the language
setting. Im not that great at scripting could you tell me what I need to
change or take out of your change script

Thanks
Ryan


"Corné Bogaarts" <does.no...@somewhere.com> wrote in message
news:eeda71hvvl2hp7ps2...@4ax.com...

Benji

unread,
May 2, 2005, 1:30:11 PM5/2/05
to
Corne,

I just need to make sure every pc is using this

1009 English - Canada


for the win32_operatingsystem.oslanguage setting

Thanks


"Corné Bogaarts" <does.no...@somewhere.com> wrote in message
news:eeda71hvvl2hp7ps2...@4ax.com...

Corné Bogaarts

unread,
May 2, 2005, 5:34:43 PM5/2/05
to
* The current 'Set'-script verifies whether a computer has the desired
settings, before applying them. That may not be stricktly necessary, but it
works fine. So you can leave most of the script as is.

* There is one line that verifies the OS-version; you'll have to change the
number in that line, as I described in the comment line. Windows 2003 is
'5.2', whereas WinXP is '5.1'.

* Take one computer and manually set the correct Language etc. Make sure to go
to the [Advanced]-tab and mark the box called 'Apply all settings ... default
user profile'. (Restart the PC)
Then run the 'Read'-script to let it write a textfile with the correct
settings.
Use the values in this text file to adjust the Sub-routine
'FillCorrectSettings' in the 'Set'-script.

* But most importantly, you need something to let the script work on all your
computers. There are several possibilities: you could get a list of all your
computers from AD, or you can make a simple text-file with all computernames
and use that in your script.

You can use the example code given here
(http://www.microsoft.com/technet/scriptcenter/scripts/templates/wmi/basic/tmwbvb26.mspx)
to do this. This script takes all computers from AD and first tries to 'ping'
each computer (to see whether it's turned on) before actually doing it's work.
The place where you can paste my script is marked very clearly.
(More similar examples are listed here:
http://www.microsoft.com/technet/scriptcenter/scripts/templates/wmi/basic/default.mspx.)

I guess you will be more than able to put the scripts together. ;-)

I've written a script that uses a text-file with one computername on each
line, but it has some disadvantages and imperfections. So I won't post it
here.


Hope this helps,

Corné

On Mon, 2 May 2005 10:27:46 -0700, "Benji" <g...@radiant.net> wrote:

>Corne,
>
>I just want to change my networked computers to Canada English from Us
>english. So infact I only want to remotely connect and change the language
>setting. Im not that great at scripting could you tell me what I need to
>change or take out of your change script
>
>Thanks
>Ryan
>"Corné Bogaarts" <does.no...@somewhere.com> wrote in message
>news:eeda71hvvl2hp7ps2...@4ax.com...
>> First script: ReadRegionalSettings.vbs
>> (Some of the lines are too long, sorry)
>>
>> '********************************************************************
>> '* Goal
>> '* This script reads the Regional Settings as they're in the Registry.
>> '* It writes them to a logfile in a format that is easily used in the

<snip>
>>
>

Benji

unread,
May 3, 2005, 4:35:57 PM5/3/05
to
Great
Thanks alot

"Corné Bogaarts" <does.no...@somewhere.com> wrote in message

news:ca4d71p332f1so5jg...@4ax.com...

Guillermo Lovato

unread,
May 27, 2005, 10:55:23 AM5/27/05
to
i'm getting a script error whenever i execute it:
line 41
char8
syntax error
code 800a03ea

any idea?

"Corné Bogaarts" <does.no...@somewhere.com> wrote in message news:eeda71hvvl2hp7ps2...@4ax.com...

Guillermo Lovato

unread,
May 27, 2005, 11:46:10 AM5/27/05
to
scratch that last error, after fixing all the wraps i get a:
"Expected end" line 88 char 4
which is the last line of the script, if i edit or add an end, it gives a "expected sub".

"Corné Bogaarts" <does.no...@somewhere.com> wrote in message news:eeda71hvvl2hp7ps2...@4ax.com...

Guillermo Lovato

unread,
May 27, 2005, 12:07:32 PM5/27/05
to
solved the problem, i deleted the end statement.
but, i execute the script and does nothing!
i changed the path of the logfile to c:, but it still does nothing :(

"Corné Bogaarts" <does.no...@somewhere.com> wrote in message news:eeda71hvvl2hp7ps2...@4ax.com...

0 new messages