Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine windows version from a VB script? [duplicate]

Possible Duplicate:
A vbscript to find windows version name and the service pack

My question says it all.

Thanks.

like image 737
mark Avatar asked Dec 27 '10 22:12

mark


People also ask

How do I find my Windows version code?

To find out which version of Windows your device is running, press the Windows logo key + R, type winver in the Open box, and then select OK.

How do I know if Visual Basic script is running?

Open Task Manager and go to Details tab. If a VBScript or JScript is running, the process wscript.exe or cscript.exe would appear in the list. Right-click on the column header and enable "Command Line". This should tell you which script file is being executed.


2 Answers

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

like image 65
ArBR Avatar answered Nov 15 '22 06:11

ArBR


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".

like image 39
thirtydot Avatar answered Nov 15 '22 04:11

thirtydot