Wednesday, April 7, 2010

QTP - How to capture System Information.

QTP - How to capture System Information.

Some time we may require to capture system information of the PC on which test is executed.

Host Name: QTP-TEST
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Build 2600
OS Manufacturer: Microsoft Corporation
OS Configuration: Workstation
OS Build Type: Multiprocessor Free
Registered Owner:
Registered Organization:
Product ID:
Original Install Date: 10/15/2009 3:04:57 PM
System Up Time: 10/21/2009 3:08:08 AM
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
BootDevice: \Device\HarddiskVolume2
System Locale: 0409
Total Physical Memory: 2005 MB
Available Physical Memory: 1245 MB
Page File: Max Size: 2048 MB
Page File: Available: 2006 MB
System Manufacturer: Dell Inc.
System Model: OptiPlex 755                
System Type: X86-based PC
Domain: WORKGROUP
Processor(s): 2 Processor(s) Installed.
    [1]: x86 Family 6 Model 15 Stepping 11 ~2327Mhz
    [2]: x86 Family 6 Model 15 Stepping 11 ~2327Mhz
BIOS Version: DELL   - d

Attaching sample code to capture above information, I capture this information to a log file so I am sending data to notepad object.



        Set oFS=createobject ("scripting.filesystemobject")
        Set oNotepad = oFS.createtextfile(gsTestSummaryFilePath)

        set dicProductType = CreateObject("Scripting.Dictionary")
        dicProductType.Add 1, "Workstation"
        dicProductType.Add 2, "Domain Controller"
        dicProductType.Add 3, "Standalone Server"
        
        set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")
        set colOS = goWMIService.InstancesOf("Win32_OperatingSystem")
        for each objOS in colOS
           oNotepad.writeline "Host Name: " & objOS.CSName
           oNotepad.writeline "OS Name: " & objOS.Caption
           oNotepad.writeline "OS Version: " & objOS.Version & " Build " & objOS.BuildNumber
           oNotepad.writeline "OS Manufacturer: " & objOS.Manufacturer
           oNotepad.writeline "OS Configuration: " & dicProductType.Item(objOS.ProductType)
           oNotepad.writeline "OS Build Type: " & objOS.BuildType
           oNotepad.writeline "Registered Owner: " & objOS.RegisteredUser
           oNotepad.writeline "Registered Organization: " & objOS.Organization
           oNotepad.writeline "Product ID: " & objOS.SerialNumber
           objWMIDateTime.Value = objOS.InstallDate
           oNotepad.writeline "Original Install Date: " & objWMIDateTime.GetVarDate
           objWMIDateTime.Value = objOS.LastBootUpTime
           oNotepad.writeline "System Up Time: " & objWMIDateTime.GetVarDate
           oNotepad.writeline "Windows Directory: " & objOS.WindowsDirectory
           oNotepad.writeline "System Directory: " & objOS.SystemDirectory
           oNotepad.writeline "BootDevice: " & objOS.BootDevice
           oNotepad.writeline "System Locale: " & objOS.Locale
'           oNotepad.writeline "Time Zone: " & "GMT" & objOS.CurrentTimezone
           oNotepad.writeline "Total Physical Memory: " & _
                        round(objOS.TotalVisibleMemorySize / 1024) & " MB"
           oNotepad.writeline "Available Physical Memory: " & _
                         round(objOS.FreePhysicalMemory / 1024) & " MB"
           oNotepad.writeline "Page File: Max Size: " & _
                         round(objOS.TotalVirtualMemorySize / 1024) & " MB"
           oNotepad.writeline "Page File: Available: " & _
                         round(objOS.FreeVirtualMemory / 1024) & " MB"
        next
        
        set colCS = goWMIService.InstancesOf("Win32_ComputerSystem")
        for each objCS in colCS
           oNotepad.writeline "System Manufacturer: " & objCS.Manufacturer
           oNotepad.writeline "System Model: " & objCS.Model
           oNotepad.writeline "System Type: " & objCS.SystemType
           oNotepad.writeline "Domain: " & objCS.Domain
           oNotepad.writeline "Processor(s): " & objCS.NumberofProcessors & _
                        " Processor(s) Installed."
        next
        
        intCount = 0
        set colProcs = goWMIService.InstancesOf("Win32_Processor")
        for each objProc in colProcs
           intCount = intCount + 1
           oNotepad.writeline vbTab & "[" & intcount & "]: " & _
                        objProc.Caption & " ~" & objProc.MaxClockSpeed & "Mhz"
        next
        
        set colBIOS = goWMIService.InstancesOf("Win32_BIOS")
        for each objBIOS in colBIOS
           oNotepad.writeline "BIOS Version: " & objBIOS.Version
        next
        
        Set dicProductType = Nothing
        Set objWMIDateTime = Nothing
        Set colOS = Nothing
        Set colCS = Nothing
        Set colProcs = Nothing
        Set colProcs = Nothing
        Set colBIOS = Nothing


        oNotepad.Close



----

No comments:

Post a Comment