0

我正在使用以下 VBScript 来检索 Windows 名称,

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set oss = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")

For Each os in oss
    msgbox os.Caption
    exit for
Next

它回来了,

Microsoft Windows 版家庭高级版

如果系统语言不是英语,则返回特定系统语言。我想知道的是,尽管使用系统语言,但始终用英文获取 Windows 名称的 VBScript 代码是什么?

4

1 回答 1

1

也许您可以使用OperatingSystemSKU而不是Caption.

根据https://techontip.wordpress.com/tag/operatingsystemsku/中的列表,您可以通过以下方式获取变体类型。但是,您将需要更多来构建操作系统版本(os.Versionos.BuildNumber),请参阅此 Wiki

Set oDict = CreateObject("Scripting.Dictionary")
oDict.Add 0,    "An unknown product"
oDict.Add 1,    "Ultimate"
oDict.Add 2,    "Home Basic"
oDict.Add 3,    "Home Premium"
oDict.Add 4,    "Enterprise"
oDict.Add 5,    "Home Basic N"
oDict.Add 6,    "Business"
oDict.Add 7,    "Server Standard"
oDict.Add 8,    "Server Datacenter (full installation)"
oDict.Add 9,    "Windows Small Business Server"
oDict.Add 10,   "Server Enterprise (full installation)"
oDict.Add 11,   "Starter"
oDict.Add 12,   "Server Datacenter (core installation)"
oDict.Add 13,   "Server Standard (core installation)"
oDict.Add 14,   "Server Enterprise (core installation)"
oDict.Add 15,   "Server Enterprise for Itanium-based Systems"
oDict.Add 16,   "Business N"
oDict.Add 17,   "Web Server (full installation)"
oDict.Add 18,   "HPC Edition"
oDict.Add 19,   "Windows Storage Server 2008 R2 Essentials"
oDict.Add 20,   "Storage Server Express"
oDict.Add 21,   "Storage Server Standard"
oDict.Add 22,   "Storage Server Workgroup"
oDict.Add 23,   "Storage Server Enterprise"
oDict.Add 24,   "Windows Server 2008 for Windows Essential Server Solutions"
oDict.Add 25,   "Small Business Server Premium"
oDict.Add 26,   "Home Premium N"
oDict.Add 27,   "Enterprise N"
oDict.Add 28,   "Ultimate N"
oDict.Add 29,   "Web Server (core installation)"
oDict.Add 30,   "Windows Essential Business Server Management Server"
oDict.Add 31,   "Windows Essential Business Server Security Server"
oDict.Add 32,   "Windows Essential Business Server Messaging Server"
oDict.Add 33,   "Server Foundation"
oDict.Add 34,   "Windows Home Server 2011"
oDict.Add 35,   "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions"
oDict.Add 36,   "Server Standard without Hyper-V"
oDict.Add 37,   "Server Datacenter without Hyper-V (full installation)"
oDict.Add 38,   "Server Enterprise without Hyper-V (full installation)"
oDict.Add 39,   "Server Datacenter without Hyper-V (core installation)"
oDict.Add 40,   "Server Standard without Hyper-V (core installation)"
oDict.Add 41,   "Server Enterprise without Hyper-V (core installation)"
oDict.Add 42,   "Microsoft Hyper-V Server"
oDict.Add 43,   "Storage Server Express (core installation)"
oDict.Add 44,   "Storage Server Standard (core installation)"
oDict.Add 45,   "Storage Server Workgroup (core installation)"
oDict.Add 46,   "Storage Server Enterprise (core installation)"
oDict.Add 47,   "Starter N"
oDict.Add 48,   "Professional"
oDict.Add 49,   "Professional N"
oDict.Add 50,   "Windows Small Business Server 2011 Essentials"
oDict.Add 51,   "Server For SB Solutions"
oDict.Add 52,   "Server Solutions Premium"
oDict.Add 53,   "Server Solutions Premium (core installation)"
oDict.Add 54,   "Server For SB Solutions EM"
oDict.Add 55,   "Server For SB Solutions EM"
oDict.Add 56,   "Windows MultiPoint Server"
oDict.Add 59,   "Windows Essential Server Solution Management"
oDict.Add 60,   "Windows Essential Server Solution Additional"
oDict.Add 61,   "Windows Essential Server Solution Management SVC"
oDict.Add 62,   "Windows Essential Server Solution Additional SVC"
oDict.Add 63,   "Small Business Server Premium (core installation)"
oDict.Add 64,   "Server Hyper Core V"
oDict.Add 66,   "Starter E"
oDict.Add 67,   "Home Basic E"
oDict.Add 68,   "Home Premium E"
oDict.Add 69,   "Professional E"
oDict.Add 70,   "Enterprise E"
oDict.Add 71,   "Ultimate E"
oDict.Add 72,   "Server Enterprise (evaluation installation)"
oDict.Add 76,   "Windows MultiPoint Server Standard (full installation)"
oDict.Add 77,   "Windows MultiPoint Server Premium (full installation)"
oDict.Add 79,   "Server Standard (evaluation installation)"
oDict.Add 80,   "Server Datacenter (evaluation installation)"
oDict.Add 84,   "Enterprise N (evaluation installation)"
oDict.Add 95,   "Storage Server Workgroup (evaluation installation)"
oDict.Add 96,   "Storage Server Standard (evaluation installation)"
oDict.Add 98,   "Windows 8 N"
oDict.Add 99,   "Windows 8 China"
oDict.Add 100,  "Windows 8 Single Language"
oDict.Add 101,  "Windows 8"
oDict.Add 103,  "Professional with Media Center"

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set oss = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")

For Each os in oss
    sType = oDict.Item(os.OperatingSystemSKU)
Next

Wscript.Echo "OS Type: " & sType
于 2014-09-05T02:31:28.243 回答