Re: VBS script for changing keyboard locale
From: Slinks (slink_meister_at_msn.com)
Date: 12/15/04
- Next message: Torgeir Bakken \(MVP\): "Re: Installing a Protocol and binding it to a network card"
- Previous message: Torgeir Bakken \(MVP\): "Re: user rights"
- In reply to: Torgeir Bakken \(MVP\): "Re: VBS script for changing keyboard locale"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Dec 2004 18:30:37 GMT
Hi,
thanks for your help
regards
Simon
Torgeir Bakken (MVP) wrote:
> Slinks wrote:
>
>> I am trying to set the standard language for the keyboard on
>> a machine, does anyone know how to do this using a vbs script?
>
> Hi
>
> NT4\Win2k\WinXP:
>
> You can do it with registry manipulation. You need to monitor what
> happens under the registry keys
>
> HKCU\Keyboard Layout\Preload\
> and
> HKCU\Keyboard Layout\Substitutes\
>
> when you do it manually to get which data to manipulate. It is only a
> few Input Locales that adds something under the Substitutes key.
>
> Under the Preload key there will be one or more values with the name 1
> (and eventually 2, 3 and so on.) It is 1 that always is the Default
> Input Locale.
>
> If you only have one Input Locale, and want to substitute it with
> another, just overwrite the one under 1. If you want to add it to the
> existing list (not substitute), you will need to find the next
> available number and add it. If you in addition want to make the new
> one default, you must swap it with 1.
>
> NOTE: You need to log out and on again to see the change!
>
> Here is a script that adds the Spanish (international) Input Locale to
> the existing list (it does not change the default value):
>
>
> '--------------------8<----------------------
>
> sSpanishPreload = "00000c0a"
> sSpanishSubstValue = "00000c0a"
> sSpanishSubstData = "0000040a"
>
> sPreloadBase = "HKCU\Keyboard Layout\Preload\"
> sSubstBase = "HKCU\Keyboard Layout\Substitutes\"
>
> Set oShell = CreateObject("WScript.Shell")
>
> iPreloadIndex = 0
>
> ' unlikely that the user has more than 20 Input Locales
> For i = 1 To 20
> If Not RegValueExists(sPreloadBase & i)Then
> ' Next available number found!
> iPreloadIndex = i
> Exit For
> Else
> sTmp = oShell.RegRead(sPreloadBase & i)
> If LCase(sTmp) = LCase(sSpanishPreload) Then
> ' Input Locale exists already. Aborting
> Exit For
> End If
> End If
> Next
>
> If iPreloadIndex > 1 Then
> ' enable taskbar icon for user selection of input locale
> oShell.RegWrite _
> "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\internat.exe", _
> "internat.exe"
> End If
>
> If iPreloadIndex <> 0 Then
> oShell.RegWrite sPreloadBase & iPreloadIndex, sSpanishPreload
> oShell.RegWrite sSubstBase & sSpanishSubstValue, sSpanishSubstData
> MsgBox "You must logoff to see the new Input Locale"
> End If
>
>
> Function RegValueExists(sRegValue)
> ' Returns True or False based of the existence of a registry value.
> Dim oShell, RegReadReturn
> Set oShell = CreateObject("WScript.Shell")
> RegValueExists = True ' init value
> On Error Resume Next
> RegReadReturn = oShell.RegRead(sRegValue)
> If Err.Number <> 0 Then
> RegValueExists = False
> End if
> On Error Goto 0
> End Function
>
> '--------------------8<----------------------
>
>
- Next message: Torgeir Bakken \(MVP\): "Re: Installing a Protocol and binding it to a network card"
- Previous message: Torgeir Bakken \(MVP\): "Re: user rights"
- In reply to: Torgeir Bakken \(MVP\): "Re: VBS script for changing keyboard locale"
- Messages sorted by: [ date ] [ thread ]