'Show system information
'Done
'System

WScript.Echo "<hr>"
WScript.Echo "OS & SP information"
WScript.Echo "------------------"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOSes
  Wscript.Echo "Caption: " & objOS.Caption 'Name
  Wscript.Echo "Version: " & objOS.Version 'Version & build
  Wscript.Echo "Build Number: " & objOS.BuildNumber 'Build
  Wscript.Echo "Build Type: " & objOS.BuildType
  Wscript.Echo "OS Type: " & objOS.OSType
  Wscript.Echo "Other Type Description: " & objOS.OtherTypeDescription
  WScript.Echo "Service Pack: " & objOS.ServicePackMajorVersion & "." & _
   objOS.ServicePackMinorVersion
Next


WScript.Echo "<hr>"
WScript.Echo "Processor information"
WScript.Echo "------------------"

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objCS In colCSes
  WScript.Echo "Computer Name: " & objCS.Name
  WScript.Echo "System Type: " & objCS.SystemType
  WScript.Echo "Number Of Processors: " & objCS.NumberOfProcessors
Next
Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
intCount = 0
For Each objProcessor in colProcessors
  WScript.Echo "Processor-" & intCount
  WScript.Echo "..........."
  WScript.Echo "Manufacturer: " & objProcessor.Manufacturer
  WScript.Echo "Name: " & objProcessor.Name
  WScript.Echo "Description: " & objProcessor.Description
  WScript.Echo "Processor ID: " & objProcessor.ProcessorID
  WScript.Echo "Address Width: " & objProcessor.AddressWidth
  WScript.Echo "Data Width: " & objProcessor.DataWidth
  WScript.Echo "Family: " & objProcessor.Family
  WScript.Echo "Maximum Clock Speed: " & objProcessor.MaxClockSpeed
  intCount = intCount+1
Next



WScript.Echo "<hr>"
WScript.Echo "Memory information"
WScript.Echo "------------------"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objCSItem In colCSItems
  WScript.Echo "Total Physical Memory: " & objCSItem.TotalPhysicalMemory/1024/1024 & " MB"
Next
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each objOSItem In colOSItems
  WScript.Echo "Free Physical Memory: " & objOSItem.FreePhysicalMemory/1024 & " MB"
  WScript.Echo "Total Virtual Memory: " & objOSItem.TotalVirtualMemorySize/1024 & " MB"
  WScript.Echo "Free Virtual Memory: " & objOSItem.FreeVirtualMemory/1024 & " MB"
  WScript.Echo "Total Visible Memory Size: " & objOSItem.TotalVisibleMemorySize/1024 & " MB"
Next

WScript.Echo "<hr>"
WScript.Echo "Disk information"
WScript.Echo "------------------"
Const HARD_DISK = 3
Const CCS_DISK = 4
Const GB = 1073741824
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer)
Set colDisks = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_LogicalDisk WHERE DriveType = " & HARD_DISK)
For Each objDisk in colDisks
  numDiskSpace = objDisk.Size
  numFreeSpace = objDisk.FreeSpace
  WScript.Echo vbCrLf & "Disk Name: " & objDisk.Name
  WScript.Echo "  Disk Size: " & Left(numDiskSpace/GB, 4) & " GB"
  WScript.Echo "  Free Space: " & Left(numFreeSpace/GB, 4) & " GB"
  WScript.Echo "  Percent Free: " & _
   Left((numFreeSpace / numDiskSpace) * 100, 4) & "%"
Next


WScript.Echo "<hr>"
WScript.Echo "Shared directories"
WScript.Echo "------------------"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery("SELECT * FROM Win32_Share")
For Each objShare in colShares
    'If Not Right(objShare.Name, 1) = "$" Then
     Wscript.Echo objShare.Name & "  " & objShare.Path
    'End If
Next

WScript.Echo "<hr>"
WScript.Echo "Mapped drives"
WScript.Echo "------------------"
Set objNetwork = WScript.CreateObject("WScript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count - 1 Step 2
    If Right(colDrives.Item(i), 1) = ":" Then
        WScript.Echo colDrives.Item(i) & vbTab & colDrives.Item (i + 1)
    End If
Next

WScript.Echo "<hr>"
WScript.Echo "IP configuration"
WScript.Echo "------------------"
Set objShell = WScript.CreateObject("WScript.Shell")
set objExecObject = objShell.Exec( "%comspec% /c ipconfig.exe /all ")

Do Until objExecObject.StdOut.AtEndOfStream
    strLine = objExecObject.StdOut.ReadLine()
    WScript.Echo strLine
Loop

WScript.Echo "<hr>"
WScript.Echo "Video card"
WScript.Echo "------------------"
strServer = "."

Set objWMI = GetObject("winmgmts://" & strServer & "/root\cimv2")
Set objInstances = objWMI.InstancesOf("Win32_VideoController",48)

For Each objInstance in objInstances
   WScript.Echo objInstance.getObjectText_
Next

WScript.Echo "<hr>"
WScript.Echo "BIOS"
WScript.Echo "------------------"
strServer = "."

Set objWMI = GetObject("winmgmts://" & strServer & "/root\cimv2")
Set objInstances = objWMI.InstancesOf("Win32_BIOS",48)

For Each objInstance in objInstances
   WScript.Echo objInstance.getObjectText_
Next

WScript.Echo "<hr>"
WScript.Echo "Manufacturer information"
WScript.Echo "------------------"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
  WScript.Echo "Name: " & objItem.Name
  WScript.Echo "Manufacturer: " & objItem.Manufacturer
  WScript.Echo "Model: " & objItem.Model
Next

WScript.Echo "<hr>"
WScript.Echo "Power Management"
WScript.Echo "------------------"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
  If Not IsNull(objItem.PowerManagementCapabilities) Then
    strPowerManagementCapabilities = _
     Join(objItem.PowerManagementCapabilities, ",")
  End If
  WScript.Echo "PowerManagementCapabilities: " & _
   strPowerManagementCapabilities
  WScript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
  Select Case objItem.PowerState
    Case 0 strPowerState = "Unknown"
    Case 1 strPowerState = "Full Power"
    Case 2 strPowerState = "Power Save - Low Power Mode"
    Case 3 strPowerState = "Power Save - Standby"
    Case 4 strPowerState = "Power Save - Unknown"
    Case 5 strPowerState = "Power Cycle"
    Case 6 strPowerState = "Power Off"
    Case 7 strPowerState = "Power Save - Warning"
  End Select
  WScript.Echo "PowerState: " & strPowerState
  Select Case objItem.PowerSupplyState
    Case 1 strPowerSupplyState = "Other"
    Case 2 strPowerSupplyState = "Unknown"
    Case 3 strPowerSupplyState = "Safe"
    Case 4 strPowerSupplyState = "Warning"
    Case 5 strPowerSupplyState = "Critical"
    Case 6 strPowerSupplyState = "Non-recoverable"
  End Select
  WScript.Echo "PowerSupplyState: " & strPowerSupplyState
Next



WScript.Echo "<hr>"
WScript.Echo "Softwares installed"
WScript.Echo "------------------"


Const msiInstallStateNotUsed      = -7
Const msiInstallStateBadConfig    = -6
Const msiInstallStateIncomplete   = -5
Const msiInstallStateSourceAbsent = -4
Const msiInstallStateInvalidArg   = -2
Const msiInstallStateUnknown      = -1
Const msiInstallStateBroken       =  0
Const msiInstallStateAdvertised   =  1
Const msiInstallStateRemoved      =  1
Const msiInstallStateAbsent       =  2
Const msiInstallStateLocal        =  3
Const msiInstallStateSource       =  4
Const msiInstallStateDefault      =  5

' Connect to Windows Installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError

' If no arguments supplied, then list all installed or advertised products
'Dim argCount:argCount = Wscript.Arguments.Count
'If (argCount = 0) Then
	Dim product, products, info, productList, version
	On Error Resume Next
	Set products = installer.Products : CheckError
	For Each product In products
		version = DecodeVersion(installer.ProductInfo(product, "Version")) : CheckError
		info = product & " = " & installer.ProductInfo(product, "ProductName") & " " & version : CheckError
		If productList <> Empty Then productList = productList & vbNewLine & info Else productList = info
	Next
	If productList = Empty Then productList = "No products installed or advertised"
	Wscript.Echo productList
	Set products = Nothing
'End If


WScript.Echo "<hr>"
WScript.Echo "CCP information"
WScript.Echo "------------------"


'query more about computer cluster
Dim productCode, property, value, message
Dim productName:productName = "Microsoft Compute Cluster Pack"
'Wscript.Arguments(0)

If Left(productName, 1) = "{" And Right(productName, 1) = "}" Then
	If installer.ProductState(productName) <> msiInstallStateUnknown Then productCode = UCase(productName)
Else
	For Each productCode In installer.Products : CheckError
		If LCase(installer.ProductInfo(productCode, "ProductName")) = LCase(productName) Then Exit For
	Next
End If
If IsEmpty(productCode) Then 
    Wscript.Echo "Product is not registered: " & productName 
Else
	Dim feature, features, parent, state, featureInfo
	Set features = installer.Features(productCode)
	For Each feature In features
		parent = installer.FeatureParent(productCode, feature) : CheckError
		If Len(parent) Then parent = " {" & parent & "}"
		state = installer.FeatureState(productCode, feature)
		Select Case(state)
			Case msiInstallStateBadConfig:    state = "Corrupt"
			Case msiInstallStateIncomplete:   state = "InProgress"
			Case msiInstallStateSourceAbsent: state = "SourceAbsent"
			Case msiInstallStateBroken:       state = "Broken"
			Case msiInstallStateAdvertised:   state = "Advertised"
			Case msiInstallStateAbsent:       state = "Uninstalled"
			Case msiInstallStateLocal:        state = "Local"
			Case msiInstallStateSource:       state = "Source"
			Case msiInstallStateDefault:      state = "Default"
			Case Else:                        state = "Unknown"
		End Select
		message = message & vbNewLine & feature & parent & " = " & state
	Next
	Set features = Nothing
	Wscript.Echo message
End If 

Function DecodeVersion(version)
	version = CLng(version)
	DecodeVersion = version\65536\256 & "." & (version\65535 MOD 256) & "." & (version Mod 65536)
End Function

Sub CheckError
	Dim message, errRec
	If Err = 0 Then Exit Sub
	message = Err.Source & " " & Hex(Err) & ": " & Err.Description
	If Not installer Is Nothing Then
		Set errRec = installer.LastErrorRecord
		If Not errRec Is Nothing Then message = message & vbNewLine & errRec.FormatText
	End If
	Wscript.Echo message
	Wscript.Quit 2
End Sub


WScript.Echo "<hr>"
WScript.Echo "Location information"
WScript.Echo "------------------"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each objOSItem In colOSItems
  WScript.Echo "Boot Device: " & objOSItem.BootDevice
  WScript.Echo "System Device: " & objOSItem.SystemDevice
  WScript.Echo "System Drive: " & objOSItem.SystemDrive
  WScript.Echo "Windows Directory: " & objOSItem.WindowsDirectory
  WScript.Echo "System Directory: " & objOSItem.SystemDirectory
Next

WScript.Echo "<hr>"
WScript.Echo "Domain or Workgroup"
WScript.Echo "------------------"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
  WScript.Echo "Name Format: " & objItem.NameFormat
  WScript.Echo "Domain: " & objItem.Domain
  WScript.Echo "Part Of Domain: " & objItem.PartOfDomain 'post-Windows 2000 only
  WScript.Echo "Workgroup: " & objItem.Workgroup 'post-Windows 2000 only
  Select Case objItem.DomainRole
    Case 0 strDomainRole = "Standalone Workstation"
    Case 1 strDomainRole = "Member Workstation"
    Case 2 strDomainRole = "Standalone Server"
    Case 3 strDomainRole = "Member Server"
    Case 4 strDomainRole = "Backup Domain Controller"
    Case 5 strDomainRole = "Primary Domain Controller"
  End Select
  WScript.Echo "Domain Role: " & strDomainRole
  strRoles = Join(objItem.Roles, ",")
  WScript.Echo "Roles: " & strRoles
  WScript.Echo "Network Server Mode Enabled: " & _
   objItem.NetworkServerModeEnabled
Next

WScript.Echo "<hr>"
WScript.Echo "User information"
WScript.Echo "------------------"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colCSItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objCSItem In colCSItems
  WScript.Echo "User Name: " & objCSItem.UserName
  WScript.Echo "Primary Owner Name: " & objCSItem.PrimaryOwnerName
  WScript.Echo "Primary Owner Contact: " & objCSItem.PrimaryOwnerContact
Next
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each objOSItem In colOSItems
  WScript.Echo "Registered User: " & objOSItem.RegisteredUser
  WScript.Echo "Number Of Users: " & objOSItem.NumberOfUsers
  WScript.Echo "Number Of Licensed Users: " & objOSItem.NumberOfLicensedUsers
Next

WScript.Echo "<hr>"
WScript.Echo "Domain information"
WScript.Echo "------------------"
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NTDomain")

For Each objItem in colItems
    Wscript.Echo "Client Site Name: " & objItem.ClientSiteName
    Wscript.Echo "DC Site Name: " & objItem.DcSiteName
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DNS Forest Name: " & objItem.DnsForestName
    Wscript.Echo "Domain Controller Address: " & _
        objItem.DomainControllerAddress
    Wscript.Echo "Domain Controller Address Type: " & _
        objItem.DomainControllerAddressType
    Wscript.Echo "Domain Controller Name: " & objItem.DomainControllerName
    Wscript.Echo "Domain GUID: " & objItem.DomainGuid
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "DS Directory Service Flag: " & objItem.DSDirectoryServiceFlag
    Wscript.Echo "DS DNS Controller Flag: " & objItem.DSDnsControllerFlag
    Wscript.Echo "DS DNS Domain Flag: " & objItem.DSDnsDomainFlag
    Wscript.Echo "DS DNS Forest Flag: " & objItem.DSDnsForestFlag
    Wscript.Echo "DS Global Catalog Flag: " & objItem.DSGlobalCatalogFlag
    Wscript.Echo "DS Kerberos Distribution Center Flag: " & _
        objItem.DSKerberosDistributionCenterFlag
    Wscript.Echo "DS Primary Domain Controller Flag: " & _
        objItem.DSPrimaryDomainControllerFlag
    Wscript.Echo "DS Time Service Flag: " & objItem.DSTimeServiceFlag
    Wscript.Echo "DS Writable Flag: " & objItem.DSWritableFlag
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Primary Owner Contact: " & objItem.PrimaryOwnerContact
    Wscript.Echo
Next

WScript.Echo "<hr>"
WScript.Echo "List hot fixes"
WScript.Echo "------------------"
Const column1 = 18
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuickFixes = objWMIService.ExecQuery _
    ("Select * from Win32_QuickFixEngineering")

For Each objQuickFix in colQuickFixes
    If Not IsEmpty(objQuickFix.Description) Then
        strID = "[" & objQuickFix.HotFixID & "]"
        intPadding = column1 - Len(strID)
        Wscript.Echo strID & Space(intPadding) & ": " & objQuickFix.Description
    End If
Next

WScript.Echo "<hr>"
WScript.Echo "Firewall properties"
WScript.Echo "------------------"
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
Wscript.Echo "Current profile type: " & objFirewall.CurrentProfileType

Wscript.Echo "Firewall enabled: " & objPolicy.FirewallEnabled
Wscript.Echo "Exceptions not allowed: " & objPolicy.ExceptionsNotAllowed
Wscript.Echo "Notifications disabled: " & objPolicy.NotificationsDisabled
Wscript.Echo "Unicast responses to multicast broadcast disabled: " & _
    objPolicy.UnicastResponsestoMulticastBroadcastDisabled

WScript.Echo "<hr>"
WScript.Echo "Cluster properties"
WScript.Echo "------------------"

set WshShell = WScript.CreateObject("WScript.Shell")
strClusterName = WshShell.ExpandEnvironmentStrings("%FL_LAUNCHER_ccp_head%")

If isEmpty(strClusterName) Then
    strClusterName = "localhost"
End If
WScript.Echo strClusterName
Set objComputeCluster = CreateObject("Microsoft.ComputeCluster.Cluster")
objComputeCluster.Connect(strClusterName)
WScript.Echo "Compute Cluster Name: " & objComputeCluster.Name
WScript.Echo "Compute Cluster Nodes:"
Set colNodes = objComputeCluster.ComputeNodes
For Each objNode In colNodes
  WScript.Echo "  " & objNode.Name
Next
WScript.Echo "Server calls asynchronous: " & objComputeCluster.IsAsynchronous
WScript.Echo "Compute Cluster Environment Variables:"
Set colEnvVars = objComputeCluster.EnvironmentVariables
For Each objEnvVar In colEnvVars
  WScript.Echo "  " & objEnvVar.Name & " = " & objEnvVar.Value
Next
WScript.Echo "Compute Cluster Parameters:"
Set colParams = objComputeCluster.Parameters
For Each objParam In colParams
  WScript.Echo "  " & objParam.Name & " = " & objParam.Value
Next

    WScript.Echo "Compute Cluster Nodes:"
    Set colNodes = objComputeCluster.ComputeNodes
    For Each objNode In colNodes
      WScript.Echo "  Node: " & objNode.Name
      WScript.Echo "    Number of Processors: " & objNode.NumberOfProcessors
      WScript.Echo "    Processor Architecture: " & _
       objNode.ProcessorArchitecture
      WScript.Echo "    Processor Speed: " & objNode.ProcessorSpeed & " MHz"
      WScript.Echo "    Memory: " & objNode.Memory & " MB"
      strStatus = ""
      Select Case objNode.Status
        Case 0 strStatus = "Ready"
        Case 1 strStatus = "Paused"
        Case 2 strStatus = "Unreachable"
        Case 3 strStatus = "Pending Approval"
        Case Else strStatus = "Status unobtainable"
      End Select
      WScript.Echo "    Status: " & strStatus
    Next



Wscript.Echo "Done"
