2010-12-27 3 views

ответ

5

От 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 

Первое информационное окно дает мне "Microsoft Windows 7 Professional".

+0

На моей машине (также для Windows 7 , BTW) объект SystemSet пуст ... – mark

+0

Тот факт, что скрипт I po sted не работает, значит, что-то «GetObject (« winmgmts: »)' не работает для вас. Googling ['winmgmts not installed'] (http://www.google.com/search?q=winmgmts+not+installed) и просматривает ваш лучший выбор. Например, первый результат говорит о «службе WMI»; вы должны убедиться, что это работает на вашем компьютере. – thirtydot

8

Вот еще одна версия:

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 

Результаты по:

Microsoft Windows XP Professional

Версия: 5.1.2600

+0

Оба dtmConvertedDate и objWMIService пустые на моей машине. – mark

Смежные вопросы