Displays OS and version number in message and APPENDS to the "OStextfile.txt". Not sure if it will work in Windows 7. Some people had problems with WMI. '-------------------- CODE ------------------------- Dim Info, myFSO, WriteStuff, dateStamp dateStamp = Date() strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems Info = objOperatingSystem.Caption & " " & objOperatingSystem.Version 'save to file Wscript.Echo Info Next Set myFSO = CreateObject("Scripting.FileSystemObject") Set WriteStuff = myFSO.OpenTextFile("OStextfile.txt", 8, True) 'append WriteStuff.WriteLine(Info) WriteStuff.WriteLine(dateStamp) WriteStuff.Close SET WriteStuff = NOTHING SET myFSO = NOTHING WScript.Quit '------------------------------------ END -------------- For more information try this. It only Echoes the info, but you can send it to a file if you assign the data to variables. ' OperatingSystem.vbs ' Purpose VBScript to document your Operating System ' Author Guy Thomas http://computerperformance.co.uk/ ' Version 1.4 - November 2005 ' ------------------------CODE-------------------------------' Option Explicit Dim objWMIService, objItem, colItems Dim strComputer, strList On Error Resume Next strComputer = "." ' WMI Connection to the object in the CIM namespace Set objWMIService = GetObject("winmgmts:\\" _ & strComputer & "\root\cimv2") ' WMI Query to the Win32_OperatingSystem Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") ' For Each... In Loop (Next at the very end) For Each objItem in colItems WScript.Echo "Machine Name: " & objItem.CSName & VbCr & _ "===================================" & vbCr & _ "Processor: " & objItem.Description & VbCr & _ "Manufacturer: " & objItem.Manufacturer & VbCr & _ "Operating System: " & objItem.Caption & VbCr & _ "Version: " & objItem.Version & VbCr & _ "Service Pack: " & objItem.CSDVersion & VbCr & _ "CodeSet: " & objItem.CodeSet & VbCr & _ "CountryCode: " & objItem.CountryCode & VbCr & _ "OSLanguage: " & objItem.OSLanguage & VbCr & _ "CurrentTimeZone: " & objItem.CurrentTimeZone & VbCr & _ "Locale: " & objItem.Locale & VbCr & _ "SerialNumber: " & objItem.SerialNumber & VbCr & _ "SystemDrive: " & objItem.SystemDrive & VbCr & _ "WindowsDirectory: " & objItem.WindowsDirectory & VbCr & _ "" Next WSCript.Quit '----------------------- END ----------------- Ted
|
| Response Title | Author and Date |
| * Nice. Both work for me under Win7 (32-bit). | Dav on Dec 31 |
| * Good, glad it works. It should also find multiple OS's. | Clippy on Dec 31 |
| Re: * Good, glad it works. It should also find multiple OS's. | on Dec 31 |
| *Pete, you are incorrigible! LOL | Clippy on Jan 1 |