如何从 VB 脚本确定 Windows 版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4542284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:55:22 来源:igfitidea点击:
How to determine windows version from a VB script?
提问by mark
Possible Duplicate:
A vbscript to find windows version name and the service pack
My question says it all.
我的问题说明了一切。
Thanks.
谢谢。
回答by ArBR
Here is another version:
这是另一个版本:
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
Wscript.Echo "Boot Device: " & os.BootDevice
Wscript.Echo "Build Number: " & os.BuildNumber
Wscript.Echo "Build Type: " & os.BuildType
Wscript.Echo "Caption: " & os.Caption
Wscript.Echo "Code Set: " & os.CodeSet
Wscript.Echo "Country Code: " & os.CountryCode
Wscript.Echo "Debug: " & os.Debug
Wscript.Echo "Encryption Level: " & os.EncryptionLevel
dtmConvertedDate.Value = os.InstallDate
dtmInstallDate = dtmConvertedDate.GetVarDate
Wscript.Echo "Install Date: " & dtmInstallDate
Wscript.Echo "Licensed Users: " & os.NumberOfLicensedUsers
Wscript.Echo "Organization: " & os.Organization
Wscript.Echo "OS Language: " & os.OSLanguage
Wscript.Echo "OS Product Suite: " & os.OSProductSuite
Wscript.Echo "OS Type: " & os.OSType
Wscript.Echo "Primary: " & os.Primary
Wscript.Echo "Registered User: " & os.RegisteredUser
Wscript.Echo "Serial Number: " & os.SerialNumber
Wscript.Echo "Version: " & os.Version
Next
Results on:
结果:
Microsoft Windows XP Professional
Version: 5.1.2600
微软视窗XP专业版
版本:5.1.2600
回答by thirtydot
From here:
从这里:
' Copyright (c) 1997-1999 Microsoft Corporation
'************************************************************************** *
'
' WMI Sample Script - Information about the OS (VBScript)
'
' This script demonstrates how to retrieve the info about the OS on the local machine from instances of
' Win32_OperatingSystem.
'
'************************************************************************** *
Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
for each System in SystemSet
WScript.Echo System.Caption
WScript.Echo System.Manufacturer
WScript.Echo System.BuildType
WScript.Echo " Version: " + System.Version
WScript.Echo " Locale: " + System.Locale
WScript.Echo " Windows Directory: " + System.WindowsDirectory
WScript.Echo " Total memory: " + System.TotalVisibleMemorySize + " bytes"
WScript.Echo " Serial Number: " + System.SerialNumber
Wscript.Echo ""
next
The first message box gives me "Microsoft Windows 7 Professional".
第一个消息框显示“Microsoft Windows 7 Professional”。