WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

User Sample Code

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

System Inventory

 Keywords:  

; Initialize WMI
strPC = '.'
oWMI = GetObject( 'winmgmts:{impersonationLevel=impersonate}!//' : strPC : '/root/cimv2' )

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



; Get Ram
oCollection= oWMI.ExecQuery("Select * from Win32_ComputerSystem")
ForEach obj In oCollection
      Name  = 'Name: ' : obj.Name
      TotalPhysicalMemory = 'TotalPhysicalMemory: ' : obj.TotalPhysicalMemory
      data = Name : @LF : TotalPhysicalMemory
      Message( 'RAM Data', data )
Next
oCollection = 0

; Get OD
oCollection= oWMI.ExecQuery("Select * from Win32_OperatingSystem")
ForEach obj In oCollection
      Caption  = 'Caption: ' : obj.Caption
      CSDVersion = 'CSDVersion: ' : obj.CSDVersion
      FreePhysicalMemory = 'FreePhysicalMemory: ' : obj.FreePhysicalMemory
      data = Caption : @LF : CSDVersion : @LF : FreePhysicalMemory
      Message( 'OS Data', data )
Next
oCollection = 0


;Get System product
oCollection = oWMI.ExecQuery( 'select * from Win32_ComputerSystemProduct' )
ForEach obj In  oCollection
   Vendor = 'Vendor: ' : obj.Vendor
   Name = 'Name: ' : obj.Name
   IdentifyingNumber = 'IdentifyingNumber: ' : obj.IdentifyingNumber
   data = Vendor : @LF : Name : @LF : IdentifyingNumber
   Message( 'System Prodcut Data', data )
Next
oCollection = 0

; Get Disk Drive
oCollection= oWMI.ExecQuery("Select * from Win32_DiskDrive")
ForEach obj In oCollection
      Model  = 'Model: ' : obj.Model
      SerialNumber = 'SerialNumber: ' : obj.SerialNumber
      InterfaceType  = 'InterfaceType: ' : obj.InterfaceType
      Size  = 'Size: ' : obj.Size
      Partitions  = 'Model: ' : obj.Partitions
      data = Model : @LF : SerialNumber  : @LF : InterfaceType  : @LF : Size : @LF :  Partitions
      Message( 'Disk Drive', data )
Next
oCollection = 0

;Get CPU
oCollection = oWMI.ExecQuery( 'select * from Win32_Processor' )
ForEach cpu In oCollection
      DeviceID = 'DeviceID: ' : cpu.DeviceID
      Availability = 'Availability: ' : cpu.Availability
      AddressWidth = 'AddressWidth: ' : cpu.AddressWidth
      CpuStatus = 'CpuStatus: ' : cpu.CpuStatus
      CurrentClockSpeed = 'CurrentClockSpeed: ' : cpu.CurrentClockSpeed
      MaxClockSpeed = 'MaxClockSpeed: ' : cpu.MaxClockSpeed
      L2CacheSize = 'L2CacheSize: ' : cpu.L2CacheSize
      L2CacheSpeed = 'L2CacheSpeed: ' : cpu.L2CacheSpeed
      Name = 'Name: ' : StrTrim(cpu.Name)
      data = DeviceID : @LF : Availability : @LF : AddressWidth: @LF: CpuStatus: @LF : CurrentClockSpeed : @LF : MaxClockSpeed : @LF : L2CacheSize: @LF: L2CacheSpeed: @LF : Name
      Message( 'CPU Data', data )
Next
oCollection = 0

;Get ip address
oCollection = oWMI.ExecQuery( 'select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE' )
ForEach obj In oCollection
      ServiceName = 'ServiceName: ' : obj.ServiceName(0)
      IPAddress = 'IPAddress: ' : obj.IPAddress(0)
      IPSubnet = 'IPSubnet: ' : obj.IPSubnet(0)
      DefaultIPGateway = 'DefaultIPGateway: ' : obj.DefaultIPGateway(0)
      MACAddress = 'MACAddress: ' : obj.MACAddress(0)
      data = ServiceName : @LF : IPAddress : @LF : IPSubnet: @LF: DefaultIPGateway: @LF : MACAddress
      Message( 'IpAddress Data', data )
Next
oCollection = 0

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;Clean up
oWmi = 0
Exit

Article ID:   W17506
File Created: 2014:01:27:16:03:18
Last Updated: 2014:01:27:16:03:18