Page 1 of 1 1
Topic Options
#179388 - 2007-08-16 09:35 AM List installed (non-MSI) applications
vroedie Offline
Fresh Scripter

Registered: 2006-10-05
Posts: 30
Hi,

I want to get a list of installed applications. I've found the following MS WMI script:

 Code:
 
$strComputer = "."
$objWMIService = GetObject("winmgmts:\\"+ $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_Product")
For Each $objItem in $colItems
    ? "Caption:" + $objItem.Caption
    ? "Description:" + $objItem.Description
    ? "Identifying Number:" + $objItem.IdentifyingNumber
    ? "Install Date:" + $objItem.InstallDate
    ? "Install Date 2:" + $objItem.InstallDate2
    ? "Install Location:" + $objItem.InstallLocation
    ? "Install State:" + $objItem.InstallState
    ? "Name:" + $objItem.Name
    ? "Package Cache:" + $objItem.PackageCache
    ? "SKU Number:" + $objItem.SKUNumber
    ? "Vendor:" + $objItem.Vendor
    ? "Version:" + $objItem.Version
Next



but this only shows MSI installed applications (I think). Is there a way to just display the same list as shown in the Add/Remove Programs?

regards,

Jeroen

Top
#179390 - 2007-08-16 09:53 AM Re: List installed (non-MSI) applications [Re: vroedie]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Here are some places to take a look.

Mail the Software Inventory
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=2&Number=117504

My Computer Info for Helpdesk use Part 4
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=139295

And this should just put the Software Inventory into a Microsoft Excel worksheet.

 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'
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

Top
#179392 - 2007-08-16 11:58 AM Re: List installed (non-MSI) applications [Re: vroedie]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Enumerate all the Uninstall keys in the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

Top
#179393 - 2007-08-16 12:04 PM Re: List installed (non-MSI) applications [Re: Witto]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
My code above already does that (and more) but working code that can be trimmed down or added to depending on your needs.
Top
#209837 - 2015-01-15 05:25 PM Re: List installed (non-MSI) applications [Re: NTDOC]
marvince Offline
Fresh Scripter

Registered: 2006-05-16
Posts: 19
Loc: Northern Hemisphere
Very helpful, thank you!
Is there a way to include the installation date?

Top
#209838 - 2015-01-15 07:34 PM Re: List installed (non-MSI) applications [Re: marvince]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
You could add another line that gives you that by adding one that extracts the "InstallDate" from the Registry section.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

Top
#209839 - 2015-01-15 08:26 PM Re: List installed (non-MSI) applications [Re: NTDOC]
marvince Offline
Fresh Scripter

Registered: 2006-05-16
Posts: 19
Loc: Northern Hemisphere
I will try this, thank you!
Top
#209840 - 2015-01-16 01:05 AM Re: List installed (non-MSI) applications [Re: marvince]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Doc's code are the best to pull the most complete list. Just a side note: Not all applications comply and you will find a lot of software that is not listed at all or is missing simple information like displayname
_________________________
!

download KiXnet

Top
#209841 - 2015-01-16 03:26 AM Re: List installed (non-MSI) applications [Re: Lonkero]
marvince Offline
Fresh Scripter

Registered: 2006-05-16
Posts: 19
Loc: Northern Hemisphere
Well I have no problem reading "InstallDate" and adding it in Excel.
But it comes out into something like 20141113 .
I do have some difficulty converting this into a date format, like 2014-11-13.
In the function GetSoftwareInfo() I use the Val() to convert to a numerical value.
In the function ImportToXLS() I added a numberformat:
$Workbook.ActiveSheet.Rows($Row).Columns(4).NumberFormat="yyyy-mm-dd"

I wonder if I do correctly, or perhaps I should just get the program folder creation date?
Sorry for the bad formatting...

Top
#209842 - 2015-01-16 03:31 AM Re: List installed (non-MSI) applications [Re: marvince]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Please look at the UDF forum for ones like serialdate or other which can do the date/time conversions for you.
Top
#209843 - 2015-01-16 04:42 PM Re: List installed (non-MSI) applications [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
If the InstallDate is simply the date without the "-" or "/" chars, just use Left() / SubStr() / Right() functions to grab the parts and reformat it.
 Code:
$InstDate = '20141113'
; reformat the date, adding dashes
$InstDate = Left($InstDate, 4) + '-' + SubStr($InstDate, 5, 2) + '-' + Right($InstDate, 2)
If you have a cTime value, it will not look anything like a date and will be a fairly large number, since it will contain the number of seconds since a specific "Epoch" date (such as Jan 1, 1970). The SerialDate or TimeConvert UDFs will convert these values. TimeConvert() allows you to specify an alternate Epoch date, which might be needed for certain data sources. See this page for more info on computer time Epoch values.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209845 - 2015-01-17 03:48 AM Re: List installed (non-MSI) applications [Re: Glenn Barnas]
marvince Offline
Fresh Scripter

Registered: 2006-05-16
Posts: 19
Loc: Northern Hemisphere
Thank you for your help!
Glenn's suggestion is the easiest and quickest for me! \:\)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 697 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.068 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org