NTDOCAdministrator
(KiX Master)
2004-04-08 02:51 AM
Mail the Software Inventory

I had a request from one our user groups asking if we had a tool or method where they could get a list of the applications installed on their desktops with the information placed into Excel so they could mail it.

Here is a script that I put together witht he help of some other members of the board as mentioned below.

It will retrieve a list of most applications in the HKLMSMWCVAppPath key. With the Path, Description, and BinFileVersion and place it into an array. Then this data is written into a MS Excel worksheet, then it is attached to a new Outlook email message.

This script would probably work in other environments with little to no changes, but if you do want to try it make sure you review the code for any specifics of your environment.


CONTRIBUTORS: - Shawn, Chris, Radimus, Jens





Code:
Break On

Dim $SO,$Software,$Application,$x,$File,$Send,$Excel,$Report
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')

$Excel = ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Excel.exe','')
$File = '%TEMP%\' + @USERID + '_' + @WKSTA + '.XLS'
$Software = QS(Split(GetSoftwareInfo(),@CRLF))
ImportToXLS($Software,$File)
$Send = SendOutlookMail('John.Doe@@MyCompany.com','Software Inventory for ' + @FULLNAME + ' on ' + @WKSTA,'Here is the software inventory for my pc ' + @WKSTA,$File)

If Exist($File)
Del $File
EndIf
Exit 1

Function ImportToXLS($List,$Output)
Dim $Excel, $Workbook, $Row, $App, $, $Error
If VarType($List) <> 8204 ; Not a string array
EXIT 1 ; ERROR_INVALID_FUNCTION
Endif
$Excel = CreateObject("Excel.Application")
If $Excel
$Excel.DisplayAlerts = 0
$Workbook = $Excel.Workbooks.Add(-4167)
If $Workbook
$Workbook.ActiveSheet.Rows(1).Columns(1).Value = "Application"
$Workbook.ActiveSheet.Rows(1).Columns(1).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(1).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).RowHeight = 25
$Workbook.ActiveSheet.Rows(1).VerticalAlignment = 2
$Workbook.ActiveSheet.Rows(1).HorizontalAlignment = -4131
$Workbook.ActiveSheet.Rows(1).Columns(2).Value = "Path"
$Workbook.ActiveSheet.Rows(1).Columns(2).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(2).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(3).Value = "Version"
$Workbook.ActiveSheet.Rows(1).Columns(3).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(3).Font.Bold = -1
$Row = 2
For Each $App In $List
If Instr($App,"*")
$Workbook.ActiveSheet.Rows($Row).Columns(1).Value = Split($App,"*")[0]
$Workbook.ActiveSheet.Rows($Row).Columns(2).Value = Split($App,"*")[1]
$Workbook.ActiveSheet.Rows($Row).Columns(3).Value = Split($App,"*")[2]
$Row=$Row+1
Endif
Next
; This line adds a hyperlink into the worksheet
; $= $Workbook.ActiveSheet.Hyperlinks.Add($Workbook.ActiveSheet.Range("D4"),"http://www.kixhelp.com",,"For further information on KiXtart please go here", "KiXhelp")

$= $Workbook.ActiveSheet.Columns(1).AutoFit
$= $Workbook.ActiveSheet.Columns(2).AutoFit
$= $Workbook.ActiveSheet.Columns(3).AutoFit
$= $Workbook.ActiveSheet.Select
$Workbook.ActiveSheet.Name = "Software Inventory"
Endif
$= $WorkBook.SaveAs($Output)
$Workbook = 0
$Excel.Quit()
$Excel = 0
Endif
EXIT @ERROR
EndFunction
 
Function GetSoftwareInfo()
Dim $HKLMAppPaths1, $HKLMAppPaths2, $App1, $App2, $Key, $SoftInfo, $Path,$AppName,$AppVer
Dim $DisplayName, $DisplayVersion, $FileVer
$HKLMAppPaths1 = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'
$HKLMAppPaths2 = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
$App1=ArrayEnumKey($HKLMAppPaths1)
$App2=ArrayEnumKey($HKLMAppPaths2)
For Each $Key in $App1
$Path = ReadValue($HKLMAppPaths1 + "\" + $Key,"")
If Len($Path)
If InStr($Path,'%') $Path = ExpandEnvironmentVars($Path) EndIf
If InStr($Path,'"') $Path=Split($Path,'"')[1] EndIf
$Path = IIF(InStr($Key,'WRITE.EXE'),'',$Path)
$Path = IIF(InStr($Key,'winzip.exe'),'',$Path)
If Trim(GetFileVersion($Path,'FileDescription')) <> ""
If Trim(GetFileVersion($Path,'BinFileVersion'))='0.0.0.0'
$FileVer = 'FileVersion'
Else
$FileVer = 'BinFileVersion'
EndIf
$SoftInfo = $SoftInfo + Trim(GetFileVersion($Path,'FileDescription')) + CHR(42)
+ $Path + CHR(42) + Trim(GetFileVersion($Path,$FileVer)) + @CRLF
EndIf
EndIf
Next
For Each $Key in $App2
$DisplayName = ReadValue($HKLMAppPaths2 + "\" + $Key,'DisplayName')
$DisplayVersion = ReadValue($HKLMAppPaths2 + "\" + $Key,'DisplayVersion')
$DisplayName = IIF(InStr($SoftInfo,$DisplayName),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'ACDSee'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Acrobat 6.0'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Illustrator'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Photoshop 5.5'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Photoshop 6.0'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Photoshop 7.0'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Reader'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Alcohol 120'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Dreamweaver MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Fireworks MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Flash MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'FreeHand MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'LiveReg'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'LiveUpdate'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'MSN Messenger'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Macromedia FreeHand'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Microsoft Office FrontPage'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Microsoft Outlook'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Net2Phone'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'RoboHelp Office'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'SnagIt'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Symantec AntiVirus'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Windows Media Encoder'),'',$DisplayName)
If Len($DisplayName)
If Len($DisplayVersion)
$SoftInfo = $SoftInfo + Trim($DisplayName) + CHR(42) + Trim($Key) + CHR(42) + Trim($DisplayVersion) + @CRLF
EndIf
EndIf
Next
$GetSoftwareInfo=$SoftInfo
EndFunction


Function ArrayEnumKey($regsubkey)
Dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
If Not KeyExist($regsubkey)
Exit 87
EndIf
$subkeycounter=0
Do
$currentsubkey=EnumKey($regsubkey,$subkeycounter)
If Not @ERROR
ReDim Preserve $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
EndIf
Until @ERROR
$arrayenumkey=$subkeyarray
Exit 0
EndFunction

Function QS($a)
DIM $b[32],$c[32],$d,$e,$f,$g,$h,$i,$j,$k,$l
$b[0]=0
$c[0]=Ubound($a)
$d=0
While $d >=0
$e=$b[$d]
$f=$c[$d]
While $e < $f
$h=$e+($f-$e)/2
$k=$a[$e]
$A[$e]=$A[$h]
$A[$h]=$k
$i=$e+1
$j=$f
$l=0
Do
While ($i<$j) And $A[$e] > $A[$i]
$i=$i+1
Loop
While ($j>=$i) And $A[$j] > $A[$e]
$j=$j-1
Loop
IF $i>=$j
$l=1
Else
$k=$A[$i]
$A[$i]=$A[$j]
$A[$j]=$k
$j=$j-1
$i=$i+1
EndIf
Until $l=1
$k=$a[$e]
$a[$e]=$a[$j]
$a[$j]=$k
$g=$j
If $g-$e <= $f - $g
If $g+1 < $f
$b[$d]=$g+1
$c[$d]=$f
$d=$d+1
EndIf
$f=$g-1
Else
If $g-1 > $e
$b[$d]=$e
$c[$d]=$g-1
$d=$d+1
EndIf
$e=$g+1
EndIf
Loop
$d=$d-1
Loop
$qs=$a
EndFunction

Function SendOutlookMail($To, $Subject, optional $Body, optional $Attachment)
Dim $objOutlook, $Msg, $Recip, $Attach, $Deliver
$objOutlook = CreateObject("Outlook.Application")
$Msg = $objOutlook.CreateItem(0)
$Msg.Subject = ($Subject)
$Msg.Body = ($Body + @CRLF)
$Recip = $Msg.Recipients.Add($To)
If Not $Recip.Resolve
$Msg.Display
EndIf
$Msg.attachments.add($Attachment)
$Msg.Display
; $Deliver = $Msg.Send
$objOutlook = ""
EndFunction




Radimus
(KiX Supporter)
2004-04-08 04:06 AM
Re: Mail the Software Inventory

not to kibbitz your excellent inventory/export routine, but I'd just use Open/writeline/close into a CSV. In this case, since all the data is already in an array, I'd just use WriteFile() to dump the array to a file. There would only be issues if any of the fields had commas... (may want to a joinsplit on each element and replace with a period)

It would work out about the same... as excel would still open it. And the code (and output) would be much lighter

and to nitpick... I'd call the function ExportToXLS()...


NTDOCAdministrator
(KiX Master)
2004-04-08 04:50 AM
Re: Mail the Software Inventory

No kibbitz at all.

You can take just about any task known to man and ask a dozen different people to do it, and you will end up with different solutions.

I like the idea and control of directly using Excel myself. This solution is not for everyone and makes Excel and Outlook a requirement, but for our environment it works quite well.


NTDOCAdministrator
(KiX Master)
2004-04-12 10:35 PM
Re: Mail the Software Inventory

I've updated the code here to use the revised GetSoftwareInfo() UDF from here

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB14&Number=116520



Trackz
(Fresh Scripter)
2004-04-15 03:26 PM
Re: Mail the Software Inventory

Very nice work..
i won't use this to send emails to any addres. will convert this with some code to add info to a MySQL db.. Thanx sofar!


Moved my question to URL: http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=116475

So this one can be deleted


NTDOCAdministrator
(KiX Master)
2004-04-16 08:28 PM
Re: Mail the Software Inventory

Glad you like it. I hope to add some more information to it and start to insert the data into a SQL 2000 database soon.

ClientMaster
(Fresh Scripter)
2005-03-02 05:59 AM
Re: Mail the Software Inventory

This is great.
A couple of minor modifications and it works wonders.
Thanks guys..


ClientMaster
(Fresh Scripter)
2005-03-02 10:16 AM
Re: Mail the Software Inventory

Just noticed one thing..

If an key in the uninstall hive doesn`t have a display version, it doesn`t get exported to the Excel file..
Any ideas on how to fix this?


NTDOCAdministrator
(KiX Master)
2005-10-11 03:51 AM
Re: Mail the Software Inventory

Since there has been a bit of interest lately of getting System information into different formats lately I thought I'd post a variation on this script.

This one does not gather the software information but simply puts in some of the user and hardware information.

This is just an example which can be altered to easily fit what it is you're wanting to put into the file.

Break On
Dim $SO,$File,$Excel,$Report
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')

$Excel = ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Excel.exe','')
If Not $Excel Quit 1 EndIf
$File = '%TEMP%\' + @USERID + '_' + @WKSTA + '.XLS'

If Exist($File)
DEL $File
EndIf

Global $Admin,$Ram,$FreeSpace,$ComputerMfg,$ComputerModel,$MyBIOSInfo,$Serial
$Admin = IIf(InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544')),'Yes','No')
$RAM = MemorySize()
$FreeSpace = DiskSpace(,1)
$ComputerMfg = WMIQuery("Manufacturer","Win32_ComputerSystem")[0]
$ComputerModel = WMIQuery("Model","Win32_ComputerSystem")[0]
$MyBIOSInfo = GetBIOSInfo()
$Serial = $MyBIOSInfo[3]

SendToXLS($File)

If Exist($File)
$Report = $Excel+CHR(32)+$File
RUN $Report
EndIf
Exit 1

Function SendToXLS($Output)
Dim $Excel, $Workbook, $Row, $App, $AF, $Error
$Excel = CreateObject("Excel.Application")
If $Excel
$Excel.DisplayAlerts = 0
$Workbook = $Excel.Workbooks.Add(-4167)
If $Workbook
$Workbook.ActiveSheet.Rows(1).Columns(1).Value = "DATE"
$Workbook.ActiveSheet.Rows(1).Columns(1).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(1).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).RowHeight = 12.75
$Workbook.ActiveSheet.Rows(1).VerticalAlignment = 2
$Workbook.ActiveSheet.Rows(1).HorizontalAlignment = -4131
$Workbook.ActiveSheet.Rows(1).Columns(2).Value = "COMPUTER"
$Workbook.ActiveSheet.Rows(1).Columns(2).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(2).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(3).Value = "IP"
$Workbook.ActiveSheet.Rows(1).Columns(3).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(3).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(4).Value = "MAC"
$Workbook.ActiveSheet.Rows(1).Columns(4).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(4).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(5).Value = "USERID"
$Workbook.ActiveSheet.Rows(1).Columns(5).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(5).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(6).Value = "FULLNAME"
$Workbook.ActiveSheet.Rows(1).Columns(6).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(6).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(7).Value = "ADMIN"
$Workbook.ActiveSheet.Rows(1).Columns(7).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(7).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(8).Value = "OS"
$Workbook.ActiveSheet.Rows(1).Columns(8).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(8).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(9).Value = "SP"
$Workbook.ActiveSheet.Rows(1).Columns(9).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(9).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(10).Value = "CPU"
$Workbook.ActiveSheet.Rows(1).Columns(10).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(10).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(11).Value = "SPEED"
$Workbook.ActiveSheet.Rows(1).Columns(11).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(11).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(12).Value = "MEMORY"
$Workbook.ActiveSheet.Rows(1).Columns(12).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(12).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(13).Value = "FREESPACE"
$Workbook.ActiveSheet.Rows(1).Columns(13).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(13).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(14).Value = "MFG"
$Workbook.ActiveSheet.Rows(1).Columns(14).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(14).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(15).Value = "MODEL"
$Workbook.ActiveSheet.Rows(1).Columns(15).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(15).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(16).Value = "SERIAL"
$Workbook.ActiveSheet.Rows(1).Columns(16).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(16).Font.Bold = -1
$Row = 2
$Workbook.ActiveSheet.Rows($Row).Columns(1).Value = @Date
$Workbook.ActiveSheet.Rows($Row).Columns(2).Value = @WKSTA
$Workbook.ActiveSheet.Rows($Row).Columns(3).Value = Join(Split(@IPADDRESS0,' '),'')
$Workbook.ActiveSheet.Rows($Row).Columns(4).Value = @ADDRESS
$Workbook.ActiveSheet.Rows($Row).Columns(5).Value = @UserID
$Workbook.ActiveSheet.Rows($Row).Columns(6).Value = @FullName
$Workbook.ActiveSheet.Rows($Row).Columns(7).Value = $Admin
$Workbook.ActiveSheet.Rows($Row).Columns(8).Value = @ProductType
$Workbook.ActiveSheet.Rows($Row).Columns(9).Value = @CSD
$Workbook.ActiveSheet.Rows($Row).Columns(10).Value = Trim(@CPU)
$Workbook.ActiveSheet.Rows($Row).Columns(11).Value = @MHz
$Workbook.ActiveSheet.Rows($Row).Columns(12).Value = $Ram
$Workbook.ActiveSheet.Rows($Row).Columns(13).Value = $FreeSpace
$Workbook.ActiveSheet.Rows($Row).Columns(14).Value = $ComputerMfg
$Workbook.ActiveSheet.Rows($Row).Columns(15).Value = $ComputerModel
$Workbook.ActiveSheet.Rows($Row).Columns(16).Value = $Serial
; This line adds a hyperlink into the worksheet if wanted
; $= $Workbook.ActiveSheet.Hyperlinks.Add($Workbook.ActiveSheet.Range("D1"),"http://www.winzip.com",,"WinZip", "WinZip Home Page")
$AF= $Workbook.ActiveSheet.Columns(1).AutoFit
$AF= $Workbook.ActiveSheet.Columns(2).AutoFit
$AF= $Workbook.ActiveSheet.Columns(3).AutoFit
$AF= $Workbook.ActiveSheet.Columns(4).AutoFit
$AF= $Workbook.ActiveSheet.Columns(5).AutoFit
$AF= $Workbook.ActiveSheet.Columns(6).AutoFit
$AF= $Workbook.ActiveSheet.Columns(7).AutoFit
$AF= $Workbook.ActiveSheet.Columns(8).AutoFit
$AF= $Workbook.ActiveSheet.Columns(9).AutoFit
$AF= $Workbook.ActiveSheet.Columns(10).AutoFit
$AF= $Workbook.ActiveSheet.Columns(11).AutoFit
$AF= $Workbook.ActiveSheet.Columns(12).AutoFit
$AF= $Workbook.ActiveSheet.Columns(13).AutoFit
$AF= $Workbook.ActiveSheet.Columns(14).AutoFit
$AF= $Workbook.ActiveSheet.Columns(15).AutoFit
$AF= $Workbook.ActiveSheet.Columns(16).AutoFit
$AF= $Workbook.ActiveSheet.Select
$Workbook.ActiveSheet.Name = "Sys Info " + @WKSTA
Endif
$AF = $WorkBook.SaveAs($Output)
$Workbook = 0
$Excel.Quit()
$Excel = 0
Endif
EXIT @ERROR
EndFunction


Function DiskSpace(optional $drive,$format)
Dim $objWMIService, $sWQL, $colDrives, $objDrive
If Not $drive
$drive='%WINDIR%'
EndIf
$format=Val($format)
If $format<5
$format=IIf($format=1,1024,IIf($format=2,1024.0*1024,IIf($format=3,1024.0*1024*1024,IIf($format=4,1024.0*1024*1024*1024,1))))
$diskspace=Cdbl(GetDiskSpace($drive))/$format
$diskspace=Val($diskspace)
Else
$objWMIService=GetObject('WinMgmts:root/cimv2')
$sWQL = "Select Size, FreeSpace FROM Win32_LogicalDisk WHERE Name='"+Left($drive,2)+"'"
$colDrives=$objWMIService.ExecQuery($sWQL)
For Each $objDrive in $colDrives
$diskspace=Cdbl($objDrive.FreeSpace)/Cdbl($objDrive.Size)*100
$diskspace=Val($diskspace)
Next
EndIf
$objWMIService=0
Exit @ERROR
EndFunction

Function WMIQuery($sWhat, $sFrom, Optional $sComputer, $sWhere, $x, $root)
Dim $sQuery, $objEnum, $sValue, $sItem, $TMP, $SystemSet, $, $objInstance
If Not $sComputer $sComputer="." EndIf
If InStr($sComputer,'\') $sComputer=Right($sComputer,InStrRev($sComputer,'\')) EndIf
If Not $root $root="\root\cimv2" EndIf
$sQuery = "Select " + $sWhat + " From "+ $sFrom
If $sWhere And $x $sQuery = $sQuery+" Where "+$sWhere+" = '"+$x+"'" EndIf
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$sComputer+$root)
If @ERROR Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf
$objEnum = $SystemSet.ExecQuery($sQuery)
If @ERROR Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf
For Each $objInstance in $objEnum
If $objInstance
$=Execute("$"+"sValue = $"+"objInstance."+$sWhat)
If VarType($sValue) & 8192
For Each $sItem in $sValue $tmp=$tmp+'|'+Trim($sItem) Next
Else
$tmp=$tmp+'|'+Trim($svalue)
EndIf
EndIf
Next
$WMIQuery = Split(SubStr($tmp,2),'|')
$SystemSet=0
Exit Val("&"+Right(DecToHex(@ERROR),4))
EndFunction

Function GetBIOSInfo()
Dim $sComputer, $WMIService, $BIOSItems, $BIOSName, $BIOSVersion, $SMBIOSVersion
Dim $Item, $SerialNumber, $Manufacturer, $BIOSArray[4]
$sComputer = ''
$WMIService = GetObject('WinMgmts:root/cimv2')
$BIOSItems = $WMIService.ExecQuery( "Select * from Win32_BIOS where PrimaryBIOS = true", , 48 )
For Each $Item in $BIOSItems
$BIOSName = Trim($Item.Name)
$BIOSVersion = Trim($Item.Version)
$SMBIOSVersion = Trim($Item.SMBIOSBIOSVersion)
$SerialNumber = Trim($Item.SerialNumber)
$Manufacturer = Trim($Item.Manufacturer)
Next
$BIOSArray[0]=$BIOSName $BIOSArray[1]=$BIOSVersion $BIOSArray[2]=$SMBIOSVersion $BIOSArray[3]=$SerialNumber
$BIOSArray[4]=$Manufacturer
$GetBIOSInfo=$BIOSArray
EndFunction


Co
(MM club member)
2005-10-11 03:14 PM
Re: Mail the Software Inventory

Doc,

First of all I like your script in all it formats. I myself am very interested in the Excel or Database format because you can use it to audit the Configuration Database...


jeremyschubert
(Getting the hang of it)
2006-05-17 07:03 AM
Re: Mail the Software Inventory

Hi NTDOC,

Thanks for posting such a terrific script.

Problem - when I try run it on my XP machine at home, the spread sheet opens up with only row 1, columns a - p filled out.
Tomorrow I'll try it out at my school. Does it need to be run on a computer in a domain setting?

Thanks,
Jeremy


NTDOCAdministrator
(KiX Master)
2006-05-17 07:31 AM
Re: Mail the Software Inventory

Hi Jerremy,

Thanks.

I think you're probably running the bottom script which is just some User Info
and a bit of Hardware and does not include the Software.

If you want to see all the information for the Software then you can run this one.
I've removed the actual mailing portion of the script so you should be able to run it locally with or without a network.

Some of the code could probably be written a little better now days, but for the most part if works.

My home computer returns 287 items installed.

Break On
Dim $SO,$Software,$Application,$x,$File,$Send,$Excel,$Report
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')

$Excel = ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Excel.exe','')
$File = '%TEMP%\' + @USERID + '_' + @WKSTA + '.XLS'
If Exist($File)
Del $File
EndIf
$Software = QS(Split(GetSoftwareInfo(),@CRLF))
ImportToXLS($Software,$File)

If Exist($File)
$Report = $Excel+CHR(32)+$File
RUN $Report
EndIf
Exit 1

Function ImportToXLS($List,$Output)
Dim $Excel, $Workbook, $Row, $App, $, $Error
If VarType($List) <> 8204 ; Not a string array
EXIT 1 ; ERROR_INVALID_FUNCTION
Endif
$Excel = CreateObject("Excel.Application")
If $Excel
$Excel.DisplayAlerts = 0
$Workbook = $Excel.Workbooks.Add(-4167)
If $Workbook
$Workbook.ActiveSheet.Rows(1).Columns(1).Value = "Application"
$Workbook.ActiveSheet.Rows(1).Columns(1).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(1).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).RowHeight = 25
$Workbook.ActiveSheet.Rows(1).VerticalAlignment = 2
$Workbook.ActiveSheet.Rows(1).HorizontalAlignment = -4131
$Workbook.ActiveSheet.Rows(1).Columns(2).Value = "Path"
$Workbook.ActiveSheet.Rows(1).Columns(2).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(2).Font.Bold = -1
$Workbook.ActiveSheet.Rows(1).Columns(3).Value = "Version"
$Workbook.ActiveSheet.Rows(1).Columns(3).Interior.Color = &EED2BD
$Workbook.ActiveSheet.Rows(1).Columns(3).Font.Bold = -1
$Row = 2
For Each $App In $List
If Instr($App,"*")
$Workbook.ActiveSheet.Rows($Row).Columns(1).Value = Split($App,"*")[0]
$Workbook.ActiveSheet.Rows($Row).Columns(2).Value = Split($App,"*")[1]
$Workbook.ActiveSheet.Rows($Row).Columns(3).Value = Split($App,"*")[2]
$Row=$Row+1
Endif
Next
; This line adds a hyperlink into the worksheet
; $= $Workbook.ActiveSheet.Hyperlinks.Add($Workbook.ActiveSheet.Range("D4")
; ,"http://www.kixhelp.com",,"For further information on KiXtart please go here", "KiXhelp")

$= $Workbook.ActiveSheet.Columns(1).AutoFit
$= $Workbook.ActiveSheet.Columns(2).AutoFit
$= $Workbook.ActiveSheet.Columns(3).AutoFit
$= $Workbook.ActiveSheet.Select
$Workbook.ActiveSheet.Name = "Software Inventory"
Endif
$= $WorkBook.SaveAs($Output)
$Workbook = 0
$Excel.Quit()
$Excel = 0
Endif
EXIT @ERROR
EndFunction

Function GetSoftwareInfo()
Dim $HKLMAppPaths1, $HKLMAppPaths2, $App1, $App2, $Key, $SoftInfo, $Path,$AppName,$AppVer
Dim $DisplayName, $DisplayVersion, $FileVer
$HKLMAppPaths1 = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'
$HKLMAppPaths2 = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
$App1=ArrayEnumKey($HKLMAppPaths1)
$App2=ArrayEnumKey($HKLMAppPaths2)
For Each $Key in $App1
$Path = ReadValue($HKLMAppPaths1 + "\" + $Key,"")
If Len($Path)
If InStr($Path,'%') $Path = ExpandEnvironmentVars($Path) EndIf
If InStr($Path,'"') $Path=Split($Path,'"')[1] EndIf
$Path = IIF(InStr($Key,'WRITE.EXE'),'',$Path)
$Path = IIF(InStr($Key,'winzip.exe'),'',$Path)
If Trim(GetFileVersion($Path,'FileDescription')) <> ""
If Trim(GetFileVersion($Path,'BinFileVersion'))='0.0.0.0'
$FileVer = 'FileVersion'
Else
$FileVer = 'BinFileVersion'
EndIf
$SoftInfo = $SoftInfo + Trim(GetFileVersion($Path,'FileDescription')) + CHR(42)
+ $Path + CHR(42) + Trim(GetFileVersion($Path,$FileVer)) + @CRLF
EndIf
EndIf
Next
For Each $Key in $App2
$DisplayName = ReadValue($HKLMAppPaths2 + "\" + $Key,'DisplayName')
$DisplayVersion = ReadValue($HKLMAppPaths2 + "\" + $Key,'DisplayVersion')
$DisplayName = IIF(InStr($SoftInfo,$DisplayName),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'ACDSee'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Acrobat 6.0'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Illustrator'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Photoshop 5.5'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Photoshop 6.0'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Photoshop 7.0'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Adobe Reader'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Alcohol 120'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Dreamweaver MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Fireworks MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Flash MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'FreeHand MX'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'LiveReg'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'LiveUpdate'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'MSN Messenger'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Macromedia FreeHand'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Microsoft Office FrontPage'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Microsoft Outlook'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Net2Phone'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'RoboHelp Office'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'SnagIt'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Symantec AntiVirus'),'',$DisplayName)
$DisplayName = IIF(InStr($DisplayName,'Windows Media Encoder'),'',$DisplayName)
If Len($DisplayName)
If Len($DisplayVersion)
$SoftInfo = $SoftInfo + Trim($DisplayName) + CHR(42) + Trim($Key) + CHR(42) + Trim($DisplayVersion) + @CRLF
EndIf
EndIf
Next
$GetSoftwareInfo=$SoftInfo
EndFunction


Function ArrayEnumKey($regsubkey)
Dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
If Not KeyExist($regsubkey)
Exit 87
EndIf
$subkeycounter=0
Do
$currentsubkey=EnumKey($regsubkey,$subkeycounter)
If Not @ERROR
ReDim Preserve $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
EndIf
Until @ERROR
$arrayenumkey=$subkeyarray
Exit 0
EndFunction

Function QS($a)
DIM $b[32],$c[32],$d,$e,$f,$g,$h,$i,$j,$k,$l
$b[0]=0
$c[0]=Ubound($a)
$d=0
While $d >=0
$e=$b[$d]
$f=$c[$d]
While $e < $f
$h=$e+($f-$e)/2
$k=$a[$e]
$A[$e]=$A[$h]
$A[$h]=$k
$i=$e+1
$j=$f
$l=0
Do
While ($i<$j) And $A[$e] > $A[$i]
$i=$i+1
Loop
While ($j>=$i) And $A[$j] > $A[$e]
$j=$j-1
Loop
IF $i>=$j
$l=1
Else
$k=$A[$i]
$A[$i]=$A[$j]
$A[$j]=$k
$j=$j-1
$i=$i+1
EndIf
Until $l=1
$k=$a[$e]
$a[$e]=$a[$j]
$a[$j]=$k
$g=$j
If $g-$e <= $f - $g
If $g+1 < $f
$b[$d]=$g+1
$c[$d]=$f
$d=$d+1
EndIf
$f=$g-1
Else
If $g-1 > $e
$b[$d]=$e
$c[$d]=$g-1
$d=$d+1
EndIf
$e=$g+1
EndIf
Loop
$d=$d-1
Loop
$qs=$a
EndFunction

 


jeremyschubert
(Getting the hang of it)
2006-05-17 11:22 PM
Re: Mail the Software Inventory

Hi Doc,

I've tried it out and it works well. Thanks.
Correct me if I'm wrong, but while this script takes software inventory, the script you posted above does hardware inventory. So, I'm going to try and be ambitious (for me atleast) and combine the two. I'm going to try make it so tht the software shows up on one workbook and the hardware on another.

Don't expect me to be quick at this though. Finals are coming up so I have to get all my computer labs read!.

Jeremy


NTDOCAdministrator
(KiX Master)
2006-05-18 01:17 AM
Re: Mail the Software Inventory

Cool,

Let us know how it goes guy. See, isn't KiXing FUN


Phoenix1987
(Fresh Scripter)
2007-01-09 03:22 PM
Re: Mail the Software Inventory

ive tried the software script. Its awesome.
there is only one thing. The mailing function isnt user friendly.
Maybe this script is written a while ago, but in outlook 2003 the user must press a butten 3 times before i receive the file.
1. Allow external program to use outlook (Warning could be a virus)
2. External program trying to sent email allow yes/no
3. Send button.

I was wondering and even tried it myself. Cant u make it so that there will be no mail sent, but that the file is copied to the network. That way u can also check, if the file exsist dont perform the inventarisation. So the login script is taking long for only 1 time, or untill i delete the file to refresh it.
Im a kix beginner so cant do it myself. Is there anybody that can help me with this

PLeeeeaaaseeee \:D


Phoenix1987
(Fresh Scripter)
2007-01-10 01:55 PM
Re: Mail the Software Inventory

Originally Posted By: Phoenix1987
ive tried the software script. Its awesome.
there is only one thing. The mailing function isnt user friendly.
Maybe this script is written a while ago, but in outlook 2003 the user must press a butten 3 times before i receive the file.
1. Allow external program to use outlook (Warning could be a virus)
2. External program trying to sent email allow yes/no
3. Send button.

I was wondering and even tried it myself. Cant u make it so that there will be no mail sent, but that the file is copied to the network. That way u can also check, if the file exsist dont perform the inventarisation. So the login script is taking long for only 1 time, or untill i delete the file to refresh it.
Im a kix beginner so cant do it myself. Is there anybody that can help me with this

PLeeeeaaaseeee \:D


PLease :P


Gargoyle
(MM club member)
2007-01-10 03:53 PM
Re: Mail the Software Inventory

Look at the post # #117515 just a few up from here, and it does not have the mail function enabled on it.

You can simply copy the $file to wherever you like.


Phoenix1987
(Fresh Scripter)
2007-01-10 04:46 PM
Re: Mail the Software Inventory

ok , but the script runs Excel. i dont want that. and i cant find the file anywhere \:o

Gargoyle
(MM club member)
2007-01-10 07:31 PM
Re: Mail the Software Inventory

Then remove this section -
Code:
If Exist($File)  
  $Report = $Excel+CHR(32)+$File  
  RUN $Report
EndIf
Exit 1


As to the location it tells you with this section -
Code:
$File = '%TEMP%\' + @USERID + '_' + @WKSTA + '.XLS'


To move it -
Code:
copy $file "\\server\share\directory"


Phoenix1987
(Fresh Scripter)
2007-01-11 01:06 PM
Re: Mail the Software Inventory

ok that works thanks.

But know i want if the file exist that the software script wil stop, but that he does continue with the kix


Mart
(KiX Supporter)
2007-01-11 01:59 PM
Re: Mail the Software Inventory

You could put a check in the script to see if the file already exists. You can put this code below the line where $file is filled with the filename.

Code:
If Exist($file)
	Exit
EndIf


Gargoyle
(MM club member)
2007-01-11 08:41 PM
Re: Mail the Software Inventory

Actually while Mart has the correct answer, you will need to replace this section
Code:
If Exist($File)
  Del $File
EndIf
with what he supplied.


BarryWhite
(Fresh Scripter)
2007-01-12 02:46 PM
Re: Mail the Software Inventory

NTDOC,
Great user & hardware inventory script, is it possible to run this against either a txt file of computer names or even better would be an ip subnet. Then place all info in subsequent rows.


NTDOCAdministrator
(KiX Master)
2007-01-12 08:36 PM
Re: Mail the Software Inventory

Is it possible ? Yes - Will I write the code to do it ? Maybe someday but not right now. Sorry just been too busy with other projects to spend the time on a real update that this needs to be generic enough for everyone to use.

If you're okay at scripting though the changes you need to make for yourself are not all that difficult though and you could make them and post back your suggestions for others.

In the future as I have time I will try to get back to this and update it per some requests.

.


Phoenix1987
(Fresh Scripter)
2007-01-15 04:28 PM
Re: Mail the Software Inventory

Originally Posted By: Gargoyle
Actually while Mart has the correct answer, you will need to replace this section
Code:
If Exist($File)
  Del $File
EndIf
with what he supplied.


sorry but still my entire script end. I just want this function to stop.


Gargoyle
(MM club member)
2007-01-15 06:48 PM
Re: Mail the Software Inventory

Post your modifications up to this point (the whole script please). At this point so many suggestions have been made, we need to see exactly where you are.

Also let us know exactly what the script is doing and at what point.

If you are unsure of what is going on or causing the exit, on the command line add the parameter '/d' (no quotes), and this will allow you to step through the script and see what it is doing along the way.

See these manual pages for more information -
[Running KiXtart] http://www.kixtart.org/manual/Notes/RUNNING.htm
[Debug How To] http://www.kixtart.org/manual/Commands/Debug.htm


Les
(KiX Master)
2007-01-16 01:34 AM
Re: Mail the Software Inventory

better still, put:
debug 'on'
in the code near where you know it is falling down.


Phoenix1987
(Fresh Scripter)
2007-01-16 09:11 AM
Re: Mail the Software Inventory

This is what i have.

Code:
If Not @LOGONMODE
	     Break On
EndIf

;BREAK OFF
Color w/b
Box(0,0,50,80,FULL)

At	(5,10)  "U wordt aangemeld bij De Jager Advies & Ontwerp"
At	(7,10)  "Even geduld aub...."
Color r+/n

Color w/b

Color w+/n
At ( 9,10) "Username : " ; display some text strings
At (10,10) "Full name : "
At (11,10) "Privilege : "
At (12,10) "Computername : "
At (13,10) "Domain : "
At (14,10) "Logon Server : "
At (15,10) "Operating System : "
;
Color y+/n
At ( 9,45) @userid ; ...and some macro's
At (10,45) @fullname
At (11,45) @priv
At (12,45) @wksta
At (13,45) @domain
At (14,45) @lserver
At (15,45) @ProductType

;
Sleep 1
;
Color w/b
;
SetTime @LSERVER

;..........................................................................Software script
Break On
Dim $SO,$Software,$Application,$x,$File,$Send,$Excel,$Report
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')
 
$Excel = ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Excel.exe','')
$File = '%TEMP%\' + @USERID + '_' + @WKSTA + '.XLS'
If Exist($File)
  Exit
EndIf
$Software = QS(Split(GetSoftwareInfo(),@CRLF))
ImportToXLS($Software,$File)
Copy $file "\\fileprintserver\groep\systeembeheer\software overzicht"
 
Function ImportToXLS($List,$Output)
 Dim $Excel, $Workbook, $Row, $App, $, $Error
 If VarType($List) <> 8204 ; Not a string array 
  Exit 1 ; ERROR_INVALID_FUNCTION  
 EndIf
 $Excel = CreateObject("Excel.Application")
 If $Excel
  $Excel.DisplayAlerts = 0
  $Workbook = $Excel.Workbooks.Add(-4167)
  If $Workbook
   $Workbook.ActiveSheet.Rows(1).Columns(1).Value = "Application"
   $Workbook.ActiveSheet.Rows(1).Columns(1).Interior.Color = &EED2BD
   $Workbook.ActiveSheet.Rows(1).Columns(1).Font.Bold = -1
   $Workbook.ActiveSheet.Rows(1).RowHeight = 25
   $Workbook.ActiveSheet.Rows(1).VerticalAlignment = 2
   $Workbook.ActiveSheet.Rows(1).HorizontalAlignment = -4131
   $Workbook.ActiveSheet.Rows(1).Columns(2).Value = "Path"
   $Workbook.ActiveSheet.Rows(1).Columns(2).Interior.Color = &EED2BD
   $Workbook.ActiveSheet.Rows(1).Columns(2).Font.Bold = -1
   $Workbook.ActiveSheet.Rows(1).Columns(3).Value = "Version"
   $Workbook.ActiveSheet.Rows(1).Columns(3).Interior.Color = &EED2BD
   $Workbook.ActiveSheet.Rows(1).Columns(3).Font.Bold = -1
   $Row = 2
   For Each $App in $List
    If InStr($App,"*")
     $Workbook.ActiveSheet.Rows($Row).Columns(1).Value = Split($App,"*")[0]
     $Workbook.ActiveSheet.Rows($Row).Columns(2).Value = Split($App,"*")[1]
     $Workbook.ActiveSheet.Rows($Row).Columns(3).Value = Split($App,"*")[2]
     $Row=$Row+1
    EndIf
   Next
;   This line adds a hyperlink into the worksheet 
;   $= $Workbook.ActiveSheet.Hyperlinks.Add($Workbook.ActiveSheet.Range("D4") 
;   ,"http://www.kixhelp.com",,"For further information on KiXtart please go here", "KiXhelp") 
 
   $= $Workbook.ActiveSheet.Columns(1).AutoFit
   $= $Workbook.ActiveSheet.Columns(2).AutoFit
   $= $Workbook.ActiveSheet.Columns(3).AutoFit
   $= $Workbook.ActiveSheet.Select
   $Workbook.ActiveSheet.Name = "Software Inventory"
  EndIf
  $= $WorkBook.SaveAs($Output)
  $Workbook = 0
  $Excel.Quit()
  $Excel = 0
 EndIf
 Exit @ERROR
EndFunction
  
Function GetSoftwareInfo()
  Dim $HKLMAppPaths1, $HKLMAppPaths2, $App1, $App2, $key2, $SoftInfo, $Path,$AppName,$AppVer
  Dim $DisplayName, $DisplayVersion, $FileVer
  $HKLMAppPaths1 = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'
  $HKLMAppPaths2 = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
  $App1=ArrayEnumKey($HKLMAppPaths1)
  $App2=ArrayEnumKey($HKLMAppPaths2)
  For Each $key2 in $App1
    $Path = ReadValue($HKLMAppPaths1 + "\" + $key2,"")
    If Len($Path)
      If InStr($Path,'%') $Path = ExpandEnvironmentVars($Path) EndIf
      If InStr($Path,'"') $Path=Split($Path,'"')[1] EndIf
        $Path       = IIf(InStr($key2,'WRITE.EXE'),'',$Path)
        $Path       = IIf(InStr($key2,'winzip.exe'),'',$Path)
      If Trim(GetFileVersion($Path,'FileDescription')) <> ""
        If Trim(GetFileVersion($Path,'BinFileVersion'))='0.0.0.0'
          $FileVer = 'FileVersion'
        Else
          $FileVer = 'BinFileVersion'
        EndIf
        $SoftInfo = $SoftInfo + Trim(GetFileVersion($Path,'FileDescription')) + Chr(42)
        + $Path + Chr(42) + Trim(GetFileVersion($Path,$FileVer)) + @CRLF
      EndIf
    EndIf
  Next
  For Each $key2 in $App2
    $DisplayName    = ReadValue($HKLMAppPaths2 + "\" + $key2,'DisplayName')
    $DisplayVersion = ReadValue($HKLMAppPaths2 + "\" + $key2,'DisplayVersion')
    $DisplayName    = IIf(InStr($SoftInfo,$DisplayName),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'ACDSee'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Adobe Acrobat 6.0'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Adobe Illustrator'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Adobe Photoshop 5.5'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Adobe Photoshop 6.0'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Adobe Photoshop 7.0'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Adobe Reader'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Alcohol 120'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Dreamweaver MX'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Fireworks MX'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Flash MX'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'FreeHand MX'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'LiveReg'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'LiveUpdate'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'MSN Messenger'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Macromedia FreeHand'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Microsoft Office FrontPage'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Microsoft Outlook'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Net2Phone'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'RoboHelp Office'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'SnagIt'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Symantec AntiVirus'),'',$DisplayName)
    $DisplayName    = IIf(InStr($DisplayName,'Windows Media Encoder'),'',$DisplayName)
    If Len($DisplayName)
      If Len($DisplayVersion)
        $SoftInfo = $SoftInfo + Trim($DisplayName) + Chr(42) + Trim($key2) + Chr(42) + Trim($DisplayVersion) + @CRLF
      EndIf
    EndIf
  Next
  $GetSoftwareInfo=$SoftInfo
EndFunction
 
  
Function ArrayEnumKey($regsubkey)
  Dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
  If Not KeyExist($regsubkey)
    Exit 87
  EndIf
  $subkeycounter=0
  Do
    $currentsubkey=EnumKey($regsubkey,$subkeycounter)
    If Not @ERROR
      ReDim Preserve $subkeyarray[$subkeycounter]
      $subkeyarray[$subkeycounter]=$currentsubkey
      $subkeycounter=$subkeycounter+1
    EndIf
  Until @ERROR
  $arrayenumkey=$subkeyarray
  Exit 0
EndFunction
 
Function QS($a)
Dim $b[32],$c[32],$d,$e,$f,$g,$h,$i,$j,$k,$l
$b[0]=0
$c[0]=UBound($a)
$d=0
While $d >=0
 $e=$b[$d]
 $f=$c[$d]
 While $e < $f
  $h=$e+($f-$e)/2
  $k=$a[$e]
  $A[$e]=$A[$h]
  $A[$h]=$k
  $i=$e+1
  $j=$f
  $l=0
Do
   While ($i<$j) And $A[$e] > $A[$i]
    $i=$i+1
   Loop
   While ($j>=$i) And $A[$j] > $A[$e]
    $j=$j-1
   Loop
   If $i>=$j
    $l=1
   Else
    $k=$A[$i]
    $A[$i]=$A[$j]
    $A[$j]=$k
    $j=$j-1
    $i=$i+1
   EndIf
Until $l=1
   $k=$a[$e]
   $a[$e]=$a[$j]
   $a[$j]=$k
   $g=$j
   If $g-$e <= $f - $g
    If $g+1 < $f
     $b[$d]=$g+1
     $c[$d]=$f
     $d=$d+1
    EndIf
    $f=$g-1
   Else
    If $g-1 > $e
     $b[$d]=$e
     $c[$d]=$g-1
     $d=$d+1
   EndIf
   $e=$g+1
  EndIf
 Loop
 $d=$d-1
Loop
$qs=$a
EndFunction
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::Mount network drives::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; Algemeen drives
Color y+/n
At	(17,10)	"Mounting network drives..."
Color w/b
At	(18,10)	"Mounting drive M: as Algemeen..."
   		Use M: "\\Fileprintserver\Algemeen" 
			Sleep 0.4
At (19,10)	"Mounting drive V: as Groep..."   
   		Use V: "\\Fileprintserver\Groep" 
			Sleep 0.4
At (20,10)	"Mounting drive W: as Groep2..."   
   		Use W: "\\Fileprintserver\Groep2"
   		Sleep 0.4
At (21,10)	"Mounting drive P: as %username%"		
			Use P: "\\Fileprintserver\" + @UserID + "$"
			Sleep 0.4
			
; Afdeling afhankelijke drives

If InGroup("systeembeheer") <> 0
At	(22,10)	"Mounting drive S: as Systeembeheer..." 
			Use S: "\\Fileprintserver\groep\SysteemBeheer"
			Sleep 0.4
EndIf
;
If InGroup("board") <> 0
At	(23.10)	"Mounting drive S: as Directie..." 
			Use S: "\\Fileprintserver\Directie" 
			Sleep 0.4
EndIf
;
If InGroup("Boekhouding") <> 0
At	(24,10)	"Mounting drive S: as Boekhouding..." 
			Use S: "\\Fileprintserver\Boekhouding" 
			Sleep 0.4
EndIf
;
If InGroup("Reception") <> 0
At	(25,10)	"Mounting drive S: as Receptie..." 
			Use S: "\\Fileprintserver\receptie" 
			Sleep 0.4
EndIf  
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::Adding printers:::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Color y+/n
At	(26,10) 	"Adding printers"
Color w/b
At	(27,10)	"Printer HP 2300D Toevoegen..."
If AddPrinterConnection ("\\fileprintserver\HP2300D") = 0
EndIf
At	(28,10)	"Printer HP Deskjet 1220C Toevoegen..."
If AddPrinterConnection ("\\fileprintserver\HP Deskjet 1220C printer") = 0
EndIf 
At	(29,10)	"Printer HP CLJ 3800 Toevoegen..."
If AddPrinterConnection ("\\fileprintserver\HP CLJ 3800") = 0
EndIf 
At	(30,10)	"Printer HP CLJ 4650DN Toevoegen..."
If AddPrinterConnection ("\\fileprintserver\4650DN ColorLaser") = 0
EndIf 
At	(31,10)	"Printer HP CL 4550 Toevoegen..."
If AddPrinterConnection ("\\fileprintserver\HP_CL_4550") = 0
EndIf 
At	(32,10)	"Printer DesignJet 500 Toevoegen..."
If AddPrinterConnection ("\\fileprintserver\DesignJet500") = 0
EndIf 
At	(33,10)	"Printer HP DJ 895 Toevoegen..."
If AddPrinterConnection ("\\fileprintserver\HP_DJ_895") = 0
EndIf 

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::Software scripts::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


;:::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::
;::::Check and install Adobe 8::::
;:::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::
Break on
Color r+/n
At	(35,10)	"Checking adobe version" Sleep 0.5 "." Sleep 0.5 "." Sleep 0.5 "." Sleep 0.5
Dim $key, $ar8, $
$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

;$ar6 = ReadValue($key + "Adobe Acrobat 6.0","UninstallString")
;$ar7 = ReadValue($key + "Adobe Acrobat 7.0","UninstallString")
;$ar8.oud = KeyExist("HKLM\SOFTWARE\Adobe\Acrobat Reader\8.0")

$ar8 = ReadValue($key + "{AC76BA86-7AD7-1033-7B44-A80000000002}","DisplayVersion") 

;
If $ar8 < "8.0.0"
	MessageBox("Installing Adobe reader 8.0","Installing Adobe",,10) 
	Shell '%systemroot%\system32\msiexec.exe /qb!- /i "\\fileprintserver\Groep2\Software Programs\Adobe\reader 8.0\AcroRead.msi"'
At	(36,10) 	"Updating adobe reader to version 8.0.0..." Sleep 1
Else At (37,10) 	"Adobe reader version up to Date"
EndIf
	
;If $ar6 <> ""
;	MessageBox("Acrobat 6 detected, uninstall. Parse string, add '-y' For quiet mode")
;	$leftpart=Left($uninst,InStr($uninst,"-f")-2)
;	$rightpart=Right($uninst,Len($uninst)-InStr($uninst,"-f")+1)
;	$uninst=$leftpart+" -a -x "+$rightpart
;	Shell $uninst
;EndIf
;If $ar7 <> ""
;	MessageBox("Acrobat 7 detected, uninstall. Parse string, add '-y' for quiet mode");
;	$leftpart=Left($uninst,InStr($uninst,"-f")-2)
;	$rightpart=Right($uninst,Len($uninst)-InStr($uninst,"-f")+1)
;	$uninst=$leftpart+" -a -x "+$rightpart
;	Shell $uninst
;EndIf
;If $ar8.oud <> "1"
;	MessageBox("Je hebt nog geen Adobe 8.","Adobe",,2)
;	MessageBox("Installing Adobe Reader 8.0","ESI International",,2)
;	Run "\\fileprintserver\Groep2\Software Programs\Adobe\AdbeRdr80_en_US.exe"
;	;Shell '%systemroot%\system32\msiexec.exe /qb!- /i"\\william\admin\users\adobereader\8\AdobeReader 8.0.msi"'
;	WriteValue ("HKLM\SOFTWARE\Adobe\Acrobat Reader\8.0\AdobeViewer\", "EULA", "1", "REG_DWord")
;
;EndIf
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::Checking errors:::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Color y+/n
? At (39,10) "Press any key to continue..."
Get $
?




Gargoyle
(MM club member)
2007-01-17 02:09 AM
Re: Mail the Software Inventory

Still need to where it is failing at

Phoenix1987
(Fresh Scripter)
2007-01-17 09:35 AM
Re: Mail the Software Inventory

If Exist($File)
Del $File
EndIf

this is where he stopped on that part.


Witto
(MM club member)
2007-01-17 12:16 PM
Re: Mail the Software Inventory

As far as I can see, that is not in your code. What I see in your second last reply is
Code:
If Exist($File)
  Exit
EndIf


Phoenix1987
(Fresh Scripter)
2007-01-17 02:04 PM
Re: Mail the Software Inventory

ow yea sorry thats what i ment.

Mart
(KiX Supporter)
2007-01-17 03:25 PM
Re: Mail the Software Inventory

If you want the inventory part of the script to not run if a report from a previous inventory on the specific machine or user is found you can change this:

Code:
If Exist($File)
  Exit
EndIf


to this:

Code:
If Exist($File) = 0
  ;do all inventory stuff here.
EndIf


The other parts of the script that are not doing an inventory or should always run even if the report already exists should be before the IF o rafter the EndIf depending on if the inventory depends on the specific piece of the script. Also you could call the UDF so the script is lots easier to read.
How to call UDF’s? You can put each UDF in a separate file and put this:

Code:
Call @scriptdir + "\someudf.udf"
Call @scriptdir + "\someotherudf.udf"


At the top of the script right after this:

Code:
If Not @LOGONMODE
	     Break On
EndIf


Gargoyle
(MM club member)
2007-01-17 05:34 PM
Re: Mail the Software Inventory

Ok, try it this way instead..
Code:
If Not Exist($File)
  $Software = QS(Split(GetSoftwareInfo(),@CRLF))
  ImportToXLS($Software,$File)
  Copy $file "\\fileprintserver\groep\systeembeheer\software overzicht"
EndIf


You had the If Exist Exit - not in a function but in your main script, so you said if the file is there, then exit and so it did.

You just have to follow the logic of what you are telling it to do.


Phoenix1987
(Fresh Scripter)
2007-01-18 09:14 AM
Re: Mail the Software Inventory

Originally Posted By: Gargoyle
Ok, try it this way instead..
Code:
If Not Exist($File)
  $Software = QS(Split(GetSoftwareInfo(),@CRLF))
  ImportToXLS($Software,$File)
  Copy $file "\\fileprintserver\groep\systeembeheer\software overzicht"
EndIf


You had the If Exist Exit - not in a function but in your main script, so you said if the file is there, then exit and so it did.

You just have to follow the logic of what you are telling it to do.


Doesnt work also

It stops after the in not exist line.


Mart
(KiX Supporter)
2007-01-18 09:58 AM
Re: Mail the Software Inventory

Check out my previous post. That should work.

Phoenix1987
(Fresh Scripter)
2007-01-18 11:19 AM
Re: Mail the Software Inventory

Originally Posted By: Mart
Check out my previous post. That should work.


Mart,

At first it didnt work but
I changed to value to 1 and now hes skipping the software part \:D
Thanks

Edit: I removed the file and it doest start making an niet inventory :S


Phoenix1987
(Fresh Scripter)
2007-01-18 11:36 AM
Re: Mail the Software Inventory

I got it working \:D

just move this to before the software script

Code:
Dim $File
$File = '\\fileprintserver\groep\systeembeheer\software overzicht\' + @USERID + '_' + @WKSTA + '.XLS'


Thanks mates


mrhodes
(Fresh Scripter)
2007-06-02 12:15 AM
Re: Mail the Software Inventory

I’ve been looking to find how too append the data in a new sheet in one excel doc... I’ve searched with no luck has anyone had success in doing this?

NTDOCAdministrator
(KiX Master)
2007-06-02 01:33 AM
Re: Mail the Software Inventory

Search for Excel there is a UDF and a post where it's done already.

If you can't find it I'll search for it later one.


SoCi0pAtH
(Fresh Scripter)
2008-04-30 06:08 PM
Re: Mail the Software Inventory

Hum...

This is giving me ideas.

Run from a central PC with a list of PC names on the network into excel spreadsheet.

Sheet one, row = PC name, user, serial and OS for each PC (A larger inventory might require the sheet # for the complete PC info).
Following sheet(s) is each individual PC with the rest of the information including installed software.


NTDOCAdministrator
(KiX Master)
2008-04-30 10:54 PM
Re: Mail the Software Inventory

Might be okay in a 10 workstation environment but anything much bigger and an Excel sheet would be a pain to review and could easily surpass the limits of Excel in a short period of time.

The use of a centralized DATABASE would be the ultimate goal. I've never sat down and completed it because the place where I'm at now doesn't require it. Radimus has completed one though and has posted it or part of it.

I'd check with him or do some searching for it.