the inventory script
Code:
If Not IsDeclared($_UDF_INV)
Global $_UDF_INV
EndIf
Function CollectData($InvFile)
$ip = EnumIPInfo($nic,0)
$snm = EnumIPInfo($nic,1)
$NicDesc= EnumIPInfo($nic,2)
$mygw = EnumIPInfo($nic,3)
$Mac =WMIQuery("MACAddress","Win32_NetworkAdapterConfiguration",,"Description",$NicDesc)
$Mac =Join(Split($mac,':'),'')
$Mac =Left($mac,InStr($mac,'|')-1)
$pingloop = iif(val(WMIQuery('StatusCode', 'Win32_PingStatus',,'Address','127.0.0.1')),'No Response','OK')
$pinggate = iif(val(WMIQuery('StatusCode', 'Win32_PingStatus',,'Address',$mygw)),'No Response','OK')
$pingmail = iif(val(WMIQuery('StatusCode', 'Win32_PingStatus',,'Address','fdhcmail')),'No Response','OK')
$pingproxy = iif(val(WMIQuery('StatusCode', 'Win32_PingStatus',,'Address','proxy')),'No Response','OK')
$pinginet = iif(val(WMIQuery('StatusCode', 'Win32_PingStatus',,'Address','www.yahoo.com')),'No Response','OK')
$HD =WMIQuery("Size","Win32_DiskDrive")
$hdGB =Left($hd,Len($hd)-9)
$hdMBfr =GetDiskSpace("c:")/1000
$Video =WMIQuery("Description","Win32_VideoController")
$Printer=WMIQuery("DriverName","Win32_Printer",,"SystemName","@wksta")
$modem =WMIQuery("Description","Win32_POTSModem",,"Status","OK")
$Biosv =WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")
$biosd =WMIQuery("Version","Win32_BIOS")
$Make =Trim(Split(WMIQuery("Manufacturer","Win32_ComputerSystem"))[0])
$Model =trim(WMIQuery("Model","Win32_ComputerSystem"))
Select
Case InStr("$model","pro") $Case="Desktop"
Case InStr("$model","evo") $Case="Desktop"
Case InStr("$model","opt") $Case="Desktop"
Case InStr("$model","lat") $Case="Laptop"
Case 1 $Case="Not Specified"
EndSelect
$asset =WMIQuery("SMBIOSAssetTag","Win32_SystemEnclosure")
If InStr($asset,"|")
For Each $Return in Split($asset,"|")
If $Return $asset=$Return EndIf
Next
EndIf
$SerNo =WMIQuery("SerialNumber","Win32_BIOS")
If Len($SerNo) < 2
$SerNo=WMIQuery("SerialNumber","Win32_SystemEnclosure")
If InStr($serno,"|")
For Each $Return in Split($serno,"|")
If Len($Return)<10 $serno=$Return EndIf
Next
EndIf
EndIf
$SerNo =Trim(Ucase($SerNo))
$CPUsp =WMIQuery("CurrentClockSpeed","Win32_Processor")
Select
case left($CPUsp,3) = "339" $CPUsp=3400
case left($CPUsp,3) = "319" $CPUsp=3200
case left($CPUsp,3) = "279" $CPUsp=2800
case left($CPUsp,3) = "269" $CPUsp=2600
case left($CPUsp,3) = "239" $CPUsp=2400
case left($CPUsp,3) = "229" $CPUsp=2200
case left($CPUsp,3) = "199" $CPUsp=2000
case left($CPUsp,3) = "179" $CPUsp=1800
case left($CPUsp,3) = "169" $CPUsp=1700
case left($CPUsp,3) = "139" $CPUsp=1400
case left($CPUsp,3) = "106" $CPUsp=1100
case left($CPUsp,2) = "99" $CPUsp=1000
case left($CPUsp,2) = "90" $CPUsp=900
case left($CPUsp,2) = "85" $CPUsp=850
case left($CPUsp,2) = "70" $CPUsp=700
case left($CPUsp,2) = "66" $CPUsp=667
case left($CPUsp,2) = "59" $CPUsp=600
case left($CPUsp,2) = "49" $CPUsp=500
case left($CPUsp,2) = "39" $CPUsp=400
EndSelect
$dimms =Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|")
For $a=0 to Ubound($dimms)
$=Execute("$$dimm$a=val($$dimms[$a]) / 1048576")
$=Execute("$$memory=val($$Memory)+val($$dimm$a)")
Next
$ier =ReadValue("HKLM\Software\Microsoft\Internet Explorer", "Version")
$MSOdir =ReadValue("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\excel.exe","Path")
$access =GetFileVersion("$MSOdir\msaccess.exe")
$excel =GetFileVersion("$MSOdir\excel.exe")
$outlook =GetFileVersion("$MSOdir\outlook.exe")
$powerpnt =GetFileVersion("$MSOdir\powerpnt.exe")
$pub =GetFileVersion("$MSOdir\mspub.exe")
$Word =GetFileVersion("$MSOdir\winword.exe")
$vscanver =ReadValue("HKLM\Software\Network Associates\TVD\VirusScan","szCurrentVersionNumber")
$vscaneng =ReadValue("HKLM\Software\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx","szEngineVer")
$vscandat =ReadValue("HKLM\Software\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx","szDatVersion")
If KeyExist('HKLM\SOFTWARE\Cognos')
$cogdir=ReadValue('HKLM\SOFTWARE\Cognos','CognosIni')
If Right($cogdir,2)='..' $cogdir=Split($cogdir,'..')[0] EndIf
$impver=GetFileVersion($cogdir+'bin\impuser.exe')
EndIf
$aspenexe=ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ASE.exe','')
If Exist($aspenexe) $asefiletime=GetFileTime($aspenexe) EndIf
$acroexe=ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe','')
If Exist($acroexe) $acrobat=GetFileVersion($acroexe) EndIf
$OSKey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows XP'
$spKey = arrayenumkey($OSKey)
for each $key in $SpKey
$patches = arrayenumkey($OSkey+'\'+$Key)
$hotfix = $hotfix +' ' + Join($patches,' ')
next
$hotfix = substr($hotfix,2)
$=WriteProfileString($InvFile,"Inventory","Date",@Date)
$=WriteProfileString($InvFile,"Inventory","Time",@time)
$=WriteProfileString($InvFile,"Network","IPAddress",$IP)
$=WriteProfileString($InvFile,"Network","SubnetMask",$snm)
$=WriteProfileString($InvFile,"Network","Gateway",$MyGW)
$=WriteProfileString($InvFile,"Network","Adapter",$NicDesc)
$=WriteProfileString($InvFile,"Network","Mac",$Mac)
$=WriteProfileString($InvFile,"Network","Location",$location)
$=WriteProfileString($InvFile,"Network","City",$city)
$=WriteProfileString($InvFile,"Network","PING_Loopback",$pingloop)
$=WriteProfileString($InvFile,"Network","PING_Gateway",$pinggate)
$=WriteProfileString($InvFile,"Network","PING_FDHCMail",$pingmail)
$=WriteProfileString($InvFile,"Network","PING_Proxy",$pingproxy)
$=WriteProfileString($InvFile,"Network","PING_Internet",$pinginet)
$=WriteProfileString($InvFile,"Hardware","SerialNumber",$SerNo)
$=WriteProfileString($InvFile,"Hardware","AHCATag",$Asset)
$=WriteProfileString($InvFile,"Hardware","ComputerName",@wksta)
$=WriteProfileString($InvFile,"Hardware","Make",$Make)
$=WriteProfileString($InvFile,"Hardware","Model",$Model)
$=WriteProfileString($InvFile,"Hardware","Case",$Case)
$=WriteProfileString($InvFile,"Hardware","BIOS Ver",$Biosv)
$=WriteProfileString($InvFile,"Hardware","BIOS Date",$Biosd)
$=WriteProfileString($InvFile,"Hardware","ProcessorSpeed",$CPUsp)
$=WriteProfileString($InvFile,"Hardware","HDSize",$hdGB)
$=WriteProfileString($Invfile,"Hardware","MBFree",$hdmbfr)
$=WriteProfileString($Invfile,"Hardware","Memory",$memory)
$=WriteProfileString($Invfile,"Hardware","Dimm0",$dimm0)
$=WriteProfileString($Invfile,"Hardware","Dimm1",$dimm1)
$=WriteProfileString($Invfile,"Hardware","Dimm2",$dimm2)
$=WriteProfileString($Invfile,"Hardware","Printer",$printer)
$=WriteProfileString($Invfile,"Hardware","Modem",$modem)
$=WriteProfileString($Invfile,"Hardware","Video",$video)
$=WriteProfileString($Invfile,"Software","OS",@producttype)
$=WriteProfileString($Invfile,"Software","SP",@csd)
$=WriteProfileString($Invfile,"Software","Hotfixes",$hotfix)
$=WriteProfileString($Invfile,"Software","MSAccess",$access)
$=WriteProfileString($Invfile,"Software","MSExcel",$excel)
$=WriteProfileString($Invfile,"Software","MSOutlook",$outlook)
$=WriteProfileString($Invfile,"Software","MSPowerpoint",$powerpnt)
$=WriteProfileString($Invfile,"Software","MSPublisher",$pub)
$=WriteProfileString($Invfile,"Software","MSWord",$word)
$=WriteProfileString($Invfile,"Software","InternetExplorer",$ier)
$=WriteProfileString($Invfile,"Software","McAfeeVersion",$vscanver)
$=WriteProfileString($Invfile,"Software","McAfeeEngine",$vscaneng)
$=WriteProfileString($Invfile,"Software","McAfeeDAT",$vscandat)
$=WriteProfileString($Invfile,"Software","Impromptu",$Impver)
$=WriteProfileString($Invfile,"Software","AspenFiletime",$asefiletime)
$=WriteProfileString($Invfile,"Software","AdobeAcrobat",$acrobat)
del @scriptdir +'\'+ $SerNo +'.txt'
shell 'cmd /c dir c:\*.exe /b /s > "'+@scriptdir+'"\current.txt'
$whiteDirs = ReadFile(@scriptdir + '\whitedir.txt')
$whitelist = ReadFile(@scriptdir + '\whitelist.txt')
$currentfile=ReadFile(@scriptdir + '\current.txt')
for each $file in $CurrentFile
$match = ascan($whitelist, $file)
if $match = -1 and len($file) > 1
$result = $result + chr(10) + $file
endif
next
$output = split(substr($result,2),chr(10))
$result = ''
for each $file in $output
$tag = 0
for each $dir in $whitedirs
if len($dir) > 1
if instr($file,$dir)
$tag = 1
endif
endif
next
if not $tag
$result = $result + chr(10) + $file
endif
next
$final = split(substr($result,2),chr(10))
del @scriptdir +'\current.txt'
del @scriptdir +'\'+ $SerNo +'.txt'
writefile(@scriptdir +'\'+ $SerNo +'.txt',$final)
$files = readfile(@scriptdir +'\'+ $SerNo +'.txt')
$lines=Ubound($files)
Dim $output[$lines]
For $Loop = 0 to $lines-1
$thisfile = $files[$Loop]
If Exist($thisfile)
$path = Left($thisfile,InStrRev($thisfile,'\'))
$exe = SubStr($thisfile,InStrRev($thisfile,'\')+1)
$ver = GetFileVersion($thisfile)
$name = GetFileVersion($thisfile,"ProductName")
$=writeprofilestring(@scriptdir +'\'+ $SerNo +'_Software.ini',join(split($path,' '),'_'),$exe,$ver + chr(9) + $name)
EndIf
Next
del @scriptdir +'\'+ $SerNo +'.txt'
EndFunction
Return