Deploying keyboard layout settings using SCCM 2012R2
I'm fairly new to SCCM and central deployment of registry files, so excuse me for being ignorant.
In our environment we have a few hundred thinclients (WES7, no domain members) which seem to have the wrong keyboard layout. An ex-colleague attempted to solve this problem by pushing a vbs script changing the keyboard layout as part of a task sequence without succes.
He used the following script to do this, my question is why this is not working and/or if there is an easier way to achieve the same goal (i would assume pushing a reg file would do the job in SCCM?)
On Error Resume Next
' Run with cscript to suppress dialogs: cscript.exe RegUpdateAllHKCU.vbs
Dim WshShell, RegRoot
Dim USERSID
Set WshShell = CreateObject("WScript.shell")
'==============================================
' SCRIPT BEGINS HERE
'==============================================
'
'This is where our HKCU is temporarily loaded, and where we need to write to it
RegRoot = "HKLM\TEMP"
'The username this is applicable for
SetUserName = "User"
GetUSERSID()
Load_Registry()
KeysToSet(RegRoot) ' update registry settings for this selected user
UnLoad_Registry()
'WScript.Echo vbCrLf & "Processing complete!"
WScript.Quit(0)
' |
' |
'====================================================================
Function KeysToSet(sRegistryRootToUse)
'==============================================
' Change variables here, or add additional keys
'==============================================
'
Dim strRegPathParent06
Dim strRegPathParent07
'Keyboard Layout
strRegPathParent06 = "Keyboard Layout\Preload"
strRegPathParent07 = "Keyboard Layout\Substitutes"
WshShell.RegDelete sRegistryRootToUse & "\" & strRegPathParent06 & "\1"
WshShell.RegWrite sRegistryRootToUse & "\" & strRegPathParent06 & "\1", "00000413", "REG_SZ"
WshShell.RegWrite sRegistryRootToUse & "\" & strRegPathParent07 & "\00000413", "00020409", "REG_SZ"
End Function
Function GetUSERSID
strComputer = "."
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get _
("Win32_UserAccount.Name='"& SetUserName &"',Domain='"& strComputerName &"'")
USERSID = objAccount.SID
End Function
Function Load_Registry()
Const HKEY_LOCAL_MACHINE = &H80000002
Dim sCurrentUser, sProfilePath
Dim intResultLoad
sProfilePath = "C:\Users\"
sCurrentUser = SetUsername
'Load user's HKCU into temp area under HKLM
intResultLoad = WshShell.Run("reg.exe load " & RegRoot & " " & sProfilePath & sCurrentUser & "\NTUSER.DAT",0, True)
'If intResultLoad <> 0 Then
' WScript.Echo(" *** An error occurred while loading HKCU for this user: " & sCurrentUser & vbCrLf)
'Else
' WScript.Echo(" HKCU Loaded for this user: " & sCurrentUser & vbCrLf)
'End If
End Function
Function UnLoad_Registry()
Dim intResultUnload
intResultUnload = WshShell.Run("reg.exe unload " & RegRoot,0, True) 'Unload HKCU from HKLM
'If intResultUnload <> 0 Then
' WScript.Echo(" *** An error occurred while unloading HKCU for this user: " & SetUsername & vbCrLf)
'Else
' WScript.Echo(" HKCU UN-loaded for this user: " & SetUsername & vbCrLf)
'End If
End Function
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
pjgeutjens
10 years ago
I think unless you have a user called 'User' this script won't do alot. This makes it pretty lousy as far as reusability goes...
Look into using ActiveSetup to make this change for each user that logs in. It will greatly simplify the script you'll have to run.
A primer on ActiveSetup: http://www.itninja.com/blog/view/appdeploy-articles-activesetup
Or look for a powershell way to do it.. Or like you said, 'push the reg file' but then make sure SCCM does it once for each user.
Also, just to be complete: if you're doing this during OS Deployment you should set the user locales in the response files for OSD, not in a separate TS task
Comments:
-
@OP
Note that the script that you posted would probably not work via Active Setup. Apart from potential registry access problems, it's a horrendous kludge.
There's probably a way to do this via calls to a WMI method. - anonymous_9363 10 years ago