I'd like to automate the installation of the above mentioned security patch
from MS. My environment has 2 languages: English and Japanese. I noticed
that MS has made the patches available in both languages also. How do I
programmatically differentiate between languages when using the patch? I
need to make sure that I use the English patch for the English OS and the
Japanese patch for the Japanese OS. All OSes are W2K. Thanks in advance.
Craig.
Hi
======================================================
One simple way to test it is to check the folder name on one of the system
folders, e.g.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common
Startup
E.g. to test for German OS, you can test for the substring "Dokumente und
Einstellungen" (in English OS: "Documents and Settings").
======================================================
For a more general way, WMI and the OSLanguage property in the
Win32_OperatingSystem class will give you this.
Platform SDK: Windows Management Instrumentation
Win32_OperatingSystem
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_operatingsystem.asp
For Each oOS in GetObject("winmgmts:"). _
InstancesOf("Win32_OperatingSystem")
iOSLang = oOS.OSLanguage
Next
WScript.Echo "Language version of the operating system installed: " & iOSLang
If iOSLang = 1030 Then ' hex 0406 is dec 1030
WScript.Echo "OS language is Danish"
Elseif iOSLang = 1033 Then ' hex 0409 is dec 1033
WScript.Echo "OS language is English (United States)"
Else
WScript.Echo "OS language is not defined in my list"
End If
======================================================
To automatically convert the OSLanguage number to the correct language in text:
sComputer = "." ' use "." for local computer
Set oShell = CreateObject("WScript.Shell")
On Error Resume Next
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sComputer _
& "\root\cimv2")
If Err.Number = 0 Then
Set colOperatingSystems = oWMI.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each oOS in colOperatingSystems
iOSLang = oOS.OSLanguage
sOSLangHex = Right("000" & Hex(iOSLang), 4)
Next
Const HKCU = &H80000001
Const HKLM = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\default:StdRegProv")
sOSLanguage = "Unknown" ' Init value
sKeyPath = "SOFTWARE\Classes\MIME\Database\Rfc1766"
sValueName = sOSLangHex
oReg.GetStringValue HKLM, sKeyPath, sValueName, sOSLanguage
' remove unnecessary stuff
aOSLanguage = Split(sOSLanguage, ";")
sOSLanguage = aOSLanguage(UBound(aOSLanguage))
If Instr(sOSLanguage, "(") > 0 Then
aOSLanguage = Split(sOSLanguage, "(")
sOSLanguage = Trim(aOSLanguage(0))
End If
sKeyPath = "Control Panel\International"
sValueName = "sCountry"
oReg.GetStringValue HKCU, sKeyPath, sValueName, sCountry
On Error Goto 0
WScript.Echo "OS language: " & sOSLanguage
Else
Wscript.Echo "Error, could not connect with WMI!"
End If
On Error Goto 0
======================================================
Here is a link to a varian of the script above
http://groups.google.com/groups?selm=3E5C3C87.C2491E8%40hydro.com
that will give you this type of information/output:
OS version: Microsoft Windows 2000 Professional
SP version: Service Pack 2
OS language: English
Regional Settings for user is set to: Norway
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
Thanks for the reply and the detailed answer. This enables me to get
started sooner than I expected. Thanks again.
Craig.
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3F48014D...@hydro.com...