0

winmgmts を使用せずにオペレーティング システムのバージョンを確認する方法が必要です。OS、vista、win7 などの名前を見つけるプラットフォームに依存しない方法が必要です。

4

5 に答える 5

3

2K/XP と Vista/Win7 では異なるユーザー アカウントのパスを解析する必要があります。comspec の戻り値は次のようになります: Microsoft Windows [バージョン 6.1.7600]。2k/XP はバージョン 5.x、Vista/Win7 はバージョン 6.x です。

Set shell = CreateObject("WScript.Shell")
Set getOSVersion = shell.exec("%comspec% /c ver")
version = getOSVersion.stdout.readall
wscript.echo version
Select Case True
   Case InStr(version, "n 5.") > 1 : GetOS = "XP"
   Case InStr(version, "n 6.") > 1 : GetOS = "Vista"
   Case Else : GetOS = "Unknown"
End Select
wscript.echo GetOS`
于 2012-08-12T18:31:52.353 に答える
1

VBscript:

Set oShell = CreateObject( "WScript.Shell" )
os_name=oShell.ExpandEnvironmentStrings("%OS%")
WScript.Echo os_name
于 2012-08-12T14:31:33.513 に答える
0

このページでは、一般的な Windows オペレーティング システム情報を取得するためのいくつかのラッパー ルーチンを提供します。すべて GetVersionEx API への 1 回の呼び出しを使用します。

GetVersionEx: Windows のバージョン、サービス パック、およびプラットフォーム情報

于 2012-08-12T21:27:21.477 に答える
0
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 "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 "Serial Number: " & os.SerialNumber
    Wscript.Echo "Version: " & os.Version
Next
于 2014-01-17T13:07:23.427 に答える
0

VisualBasicScript.comから:

Option Explicit 
Dim oShell 
Dim oShellExec, oStdOutputText, sText, iElement, aOS, sOS

Set oShell = CreateObject("Wscript.Shell") 
Set oShellExec = oShell.Exec("%comspec% /c ver") 
Set oStdOutputText = oShellExec.StdOut 

Do While Not oStdOutputText.AtEndOfStream 
    sText = oStdOutputText.ReadLine 
    aOS = Array("Windows 95", "Windows 98", "Windows NT", "Windows 2000", "Windows XP", "Microsoft Windows [Version") 
    For iElement = LBound(aOS) To UBound(aOS) 
      If InStr(sText, aOS(iElement)) <> 0 Then 
        If aOS(iElement) = "Microsoft Windows [Version" Then 
          If InStr(sText, "Version6.0") <> 0 Then
            sOS = "Windows Vista"
          ElseIf InStr(sText, "Version 6.1")<>0 Then
            sOS = "Windows 7"
          Else
            sOS = "Windows 2003" 
          End If
        Else 
         sOS = aOS(iElement) 
        End If 
      End If 
    Next 
Loop 
WScript.Echo sOS 
于 2012-08-12T15:28:28.003 に答える