【问题标题】:Get WIndows name in English?用英文获取 WINDOWS 名称?
【发布时间】:2014-09-02 22:29:03
【问题描述】:

我正在使用以下 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 代码是什么?

【问题讨论】:

  • 您是否尝试在命名空间限定符中传递美国英语的语言环境 ID?我相信美国英语是 1033 (0409) 所以它看起来像这样:GetObject("winmgmts:\\.\root\cimv2\ms_409")
  • 谢谢,但不幸的是这不起作用。
  • 看起来你已经找到了解决方案,但我很好奇如果写它会返回正确的标题:GetObject("winmgmts:{impersonationLevel=impersonate}[locale=ms_409]!\\" & strComputer & "\root\cimv2")。这对我有用,但我目前没有使用非英语语言,因此您的结果可能会有所不同。
  • 以特定的系统语言返回。

标签: sql vbscript createobject


【解决方案1】:

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

根据https://techontip.wordpress.com/tag/operatingsystemsku/中的列表,你可以得到下面的变体类型。但是,您将需要更多来构建操作系统版本(os.Versionos.BuildNumber),请参阅 this 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

【讨论】:

    猜你喜欢
    • 2013-04-11
    • 2014-04-06
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多