Introduction
This script sample can change the system display language in Windows.
Scenarios
Here is a scenario that in a company the default language of Windows is Japanese. But some system admins only knows Japanese but not English. And the other admins only knows English. The English admins usually go to regional setting in the control panel and change the display language to English. After they finish their tasks they need to set back the language to Japanese. And these steps are really time consuming. This script can help user to change system display language automatically.
Script
Step 1: You can run this VBScript sample by simply double-clicking. It will show a prompt message. The step is shown in the following figure.
When the script finishes running. You will see a brief message as shown below.
Here are some code snippets for your reference.
Function ChangeDisplayLanguage(LanguageTag)
Dim strComputer
Dim strValue
Dim strKeyPath
Dim objReg,str
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
str = "PreferredUILanguages"
strValue = LanguageTag
strKeyPath = "Control Panel\Desktop"
Set objReg = GetObject("winmgmts:{impersonationlevel=impersonate}\\" & strComputer &"\root\default:StdRegProv")
Dim strPath
objReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,str,strValue
MsgBox "Successfully change the system display language."
'Prompt message
Dim result,objShell
Set objShell = WScript.CreateObject("WScript.Shell")
result = MsgBox ("It will take effect after log off, do you want to log off right now?", vbYesNo, "Log off computer")
Select Case result
Case vbYes
objShell.Run("logoff")
Case vbNo
Wscript.Quit
End Select
End Function
Function ChangeDisplayLanguage(LanguageTag) Dim strComputer Dim strValue Dim strKeyPath Dim objReg,str Const HKEY_CURRENT_USER = &H80000001 strComputer = "." str = "PreferredUILanguages" strValue = LanguageTag strKeyPath = "Control Panel\Desktop" Set objReg = GetObject("winmgmts:{impersonationlevel=impersonate}\\" & strComputer &"\root\default:StdRegProv") Dim strPath objReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,str,strValue MsgBox "Successfully change the system display language." 'Prompt message Dim result,objShell Set objShell = WScript.CreateObject("WScript.Shell") result = MsgBox ("It will take effect after log off, do you want to log off right now?", vbYesNo, "Log off computer") Select Case result Case vbYes objShell.Run("logoff") Case vbNo Wscript.Quit End Select End Function
Windows PowerShell 2.0
Windows 7 or higher versionMicrosoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused
Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script
samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.