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")
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
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()...
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.
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.
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...
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
_________________________
--- Bishop Grandin Technology Department 'Either we're on time, or we're late'
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.
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
_________________________
--- Bishop Grandin Technology Department 'Either we're on time, or we're late'
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
_________________________
A mistake is Human, But to make it a real mess you need a computer.
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
PLease :P
_________________________
A mistake is Human, But to make it a real mess you need a computer.