Jump to content

Detect soft Installed


Recommended Posts

Im searching for a way to detect all software installed on a pc. I found 2 method but neither of them giving a full list!

First would be powershell (My Office didnt get detect) Link to forum

Second will be using uninstall key in reg (GitKraken didnt get detect) Link to forum

Is there another method to get all installed software? I Will post my work-in-progress script soon. Just trying to refactor my horrible code before...

PS: Im kinda new to autoit and programming in general. Also sry for my english.. It a second language.

 

Edit: Here my code that show both the script i found into the same GUI. They dont work the same way and I actually dont understand very well how they work but i would like to have a single list in a simple array. 

#RequireAdmin

#include <GuiListView.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>

Global Const $sTagAppInfoData = "UINT cbSize;UINT dwMask;ptr pszDisplayName;ptr pszVersion;ptr pszPublisher;ptr pszProductID;" & _
        "ptr pszRegisteredOwner;ptr pszRegisteredCompany;ptr pszLanguage;ptr pszSupportUrl;ptr pszSupportTelephone;" & _
        "ptr pszHelpLink;ptr pszInstallLocation;ptr pszInstallSource;ptr pszInstallDate;ptr pszContact;ptr pszComments;" & _
        "ptr pszImage;ptr pszReadmeUrl;ptr pszUpdateInfoUrl"

Global Const $sCLSID_EnumInstalledApps = "{0B124F8F-91F0-11D1-B8B5-006008059382}"
Global Const $sIID_IEnumInstalledApps = "{1BC752E1-9046-11D1-B8B3-006008059382}"
Global Const $sTagIEnumInstalledApps = "Next hresult(ptr*);Reset hresult();"

Global Const $sIID_IShellApp = "{A3E14960-935F-11D1-B8B8-006008059382}"
Global Const $sShellApp = "GetAppInfoData hresult(ptr);"

Global Const $AIM_DISPLAYNAME = 0x00000001
Global Const $AIM_VERSION = 0x00000002
Global Const $AIM_PUBLISHER = 0x00000004
Global Const $AIM_PRODUCTID = 0x00000008
Global Const $AIM_REGISTEREDOWNER = 0x00000010
Global Const $AIM_REGISTEREDCOMPANY = 0x00000020
Global Const $AIM_LANGUAGE = 0x00000040
Global Const $AIM_SUPPORTURL = 0x00000080
Global Const $AIM_SUPPORTTELEPHONE = 0x00000100
Global Const $AIM_HELPLINK = 0x00000200
Global Const $AIM_INSTALLLOCATION = 0x00000400
Global Const $AIM_INSTALLSOURCE = 0x00000800
Global Const $AIM_INSTALLDATE = 0x00001000
Global Const $AIM_CONTACT = 0x00004000
Global Const $AIM_COMMENTS = 0x00008000
Global Const $AIM_IMAGE = 0x00020000
Global Const $AIM_READMEURL = 0x00040000
Global Const $AIM_UPDATEINFOURL = 0x00080000

Global $i
Local $sSft



ShowGUI()

GUISetState()

While 1
   Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         ExitLoop
   EndSwitch
WEnd

Func GetInstalledAppsPS($iMask = $AIM_DISPLAYNAME)

   Local $oEnumInstalledApps = ObjCreateInterface($sCLSID_EnumInstalledApps, $sIID_IEnumInstalledApps, $sTagIEnumInstalledApps)
   If @error Then Return 0
   Local $pShellApp = 0
   Local $oShellApp = 0
   Local $AppInfoData = DllStructCreate($sTagAppInfoData)
   Local $pAppInfoData = DllStructGetPtr($AppInfoData)
   Local $i = 0
   Local $aArray[0][0]
   Local $iF = 1
   Local $tData = 0
   Local $sData = ""
   Local $aMax = nCol($iMask)

   While $oEnumInstalledApps.Next($pShellApp) = 0 And $pShellApp <> 0
      $oShellApp = ObjCreateInterface($pShellApp, $sIID_IShellApp, $sShellApp)
      If @error Then Return 0

      DllStructSetData($AppInfoData, "cbSize", DllStructGetSize($AppInfoData))
      DllStructSetData($AppInfoData, "dwMask", $iMask)

      $oShellApp.GetAppInfoData($pAppInfoData)

      ReDim $aArray[$iF][UBound($aMax)]

      For $i = 0 To UBound($aMax) - 1
         $tData = DllStructCreate("wchar[260]", DllStructGetData($AppInfoData, $aMax[$i] + 2))
         $sData = DllStructGetData($tData, 1)
         If $aMax[$i] = 13 Then $sData = StringMid($sData, 7, 2) & "/" & StringMid($sData, 5, 2) & "/" & StringMid($sData, 1, 4)
            $aArray[$iF - 1][$i] = ($sData = "0") ? "" : $sData
         DllStructSetData($tData, 1, "")
      Next

      $oShellApp = Null
      $iF += 1
   WEnd
   $oEnumInstalledApps = Null
   Return $aArray

EndFunc;==>GetInstalledApps

Func nCol($iMask)
   Local $aFlag[18] = [$AIM_DISPLAYNAME, $AIM_VERSION, $AIM_PUBLISHER, $AIM_PRODUCTID, $AIM_REGISTEREDOWNER, $AIM_REGISTEREDCOMPANY, _
         $AIM_LANGUAGE, $AIM_SUPPORTURL, $AIM_SUPPORTTELEPHONE, $AIM_HELPLINK, $AIM_INSTALLLOCATION, $AIM_INSTALLSOURCE, _
         $AIM_INSTALLDATE, $AIM_CONTACT, $AIM_COMMENTS, $AIM_IMAGE, $AIM_READMEURL, $AIM_UPDATEINFOURL]
   Local $iCol = 0
   Local $x = 0
   Local $aCol[18]
   For $i = 0 To UBound($aFlag) - 1
      If BitAND($iMask, $aFlag[$i]) Then
         $aCol[$x] = $i + 1
         $x += 1
      EndIf
   Next
   ReDim $aCol[$x]
   Return $aCol
EndFunc;==>nCol

; Author JSThePatriot - Modified June 20, 2010 by ripdad
Func _ComputerGetSoftware(ByRef $aSoftwareInfo)
    Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 1
    Dim $aSoftwareInfo[1][4]
    $input = inputbox ("Which Software" , "Which Software would you like to view?", 'ALL')
    If @Error = 1 Then Exit
    If $input = 'ALL' Then
    For $j = 1 To 500
        $AppKey = RegEnumKey($UnInstKey, $j)
        If @error <> 0 Then Exitloop
        If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
        ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
        $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
        $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
        $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
        $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
        $i = $i + 1

    Next
    $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
    If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)
    Return _ArraySort($aSoftwareInfo)

Else

    For $j = 1 To 500
        $AppKey = RegEnumKey($UnInstKey, $j)
        If @error <> 0 Then Exitloop
        $Reg = RegRead($UnInstKey & "\" & $AppKey, "DisplayName")
        $string = stringinstr($Reg, $input)
        If $string = 0 Then Continueloop
        ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
        $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
        $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
        $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
        $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
        $i = $i + 1

    Next
    $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
    If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)
    Return _ArraySort($aSoftwareInfo)

    Endif
EndFunc

Func ShowGUI()
    Local $aArray = GetInstalledAppsPS(BitOR($AIM_DISPLAYNAME, $AIM_VERSION, $AIM_INSTALLLOCATION))
    Global $guiMain = GUICreate('Currently Installed Software', 810, 650, -1, -1)
    Global $lvImportantSoft = GUICtrlCreateListView('Installed Software|Display Version|Install Location', 5, 5, 800, 300)
    Global $lvOtherSoft = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Install Location', 5, 335, 800, 300)
    _ArraySort($aArray)
    _GUICtrlListView_AddArray($lvImportantSoft, $aArray)
    _GUICtrlListView_SetColumnWidth($lvImportantSoft, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($lvImportantSoft, 3, $LVSCW_AUTOSIZE)

    _ComputerGetSoftware($sSft)
    For $i = 1 To ubound($sSft) - 1
        GUICtrlCreateListViewItem($i & '|' & $sSft[$i][0] & '|' & $sSft[$i][1] & '|' & $sSft[$i][2] & '|' & $sSft[$i][3], $lvOtherSoft)
    Next
EndFunc

 

Edited by MikiiTakagi
Link to comment
Share on other sites

From your second link, This key

 "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

only contains 64bit software installs on a 64bit system

you also need to look in at this key, 

 "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"

For 32bit software installations

Link to comment
Share on other sites

You could also use WMI, more specifically, the Win32_Product class.  However, it will only tell you about software that was installed by Windows Installer.  It has no idea about side-loaded, portable apps, or any other apps that were not installed using Windows Installer.  For those types of apps, you're on your own in terms of scanning for and identifying them.

Edited by TheXman
Link to comment
Share on other sites

32 minutes ago, MikiiTakagi said:

Even if i run either of those, The result are the same. GitKraken (as exemple) is not detected with either! I know it inside appdata of the user. Don't know if that maybe the problem of this script.

AppData only contains the application(s) configurations. It does not = software installed.

When an App is uninstalled it may not remove the appdata information because the installer didn't put it there, the App placed it there.

Edited by Shark007
Link to comment
Share on other sites

GitKraken is installed into appData! I will try to look into the WMI to get the remaining info I need. Trying to find office from another computer just to try, i noticed that Itune is not detected too. My collegue told me is Itunes is installed from Windows store

Link to comment
Share on other sites

42 minutes ago, Shark007 said:

AppData only contains the application(s) configurations. It does not = software installed.

That's not always true, Chrome can be installed a user's AppData folder if it can't install itself somewhere else. I ran into this a lot when I was managing a university's student computer network and found Chrome installed by user's even though they had no rights to install software, had to come up with a GP that prevented the installer from running.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Im gonna be honest, i dont really understand the registry UDFs... But i found out a PC with office 2016 detected by the code I sent. Don't know if it because office it probably half-installed with windows by default? All of it was test on windows 10 too.

Link to comment
Share on other sites

Remember to use HKLM and HKLM64 when compiling as 32-bit otherwise you're only returning 32-bit hive, this should display all items that show up in Programs and Features:

#include <Array.au3>
Global $g_aSoftware[1][6] = [["Registry Hive", "DisplayName", "DisplayVersion", "Publisher", "UninstallString"]]

;~ Current User Hive
_ProgramsAndFeaturesList("HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
;~ 32-Bit HKEY_LOCAL_MACHINE Hive
_ProgramsAndFeaturesList("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
;~ 64-Bit HKEY_LOCAL_MACHINE Hive
_ProgramsAndFeaturesList("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
_ArrayDisplay($g_aSoftware)

Func _ProgramsAndFeaturesList($_sRegHive)
    Local $sRegEnumKey, $i = 1
    While 1
        $sRegEnumKey = RegEnumKey($_sRegHive, $i)
            If @error Then ExitLoop
        If Not RegRead($_sRegHive & "\" & $sRegEnumKey, "DisplayName") = "" Then
            $x = UBound($g_aSoftware) + 1
            ReDim $g_aSoftware[$x][5]
            $x = UBound($g_aSoftware) - 1
            $g_aSoftware[$x][0] = $_sRegHive & "\" & $sRegEnumKey
            $g_aSoftware[$x][1] = RegRead($g_aSoftware[$x][0], "DisplayName")
            $g_aSoftware[$x][2] = RegRead($g_aSoftware[$x][0], "DisplayVersion")
            $g_aSoftware[$x][3] = RegRead($g_aSoftware[$x][0], "Publisher")
            $g_aSoftware[$x][4] = RegRead($g_aSoftware[$x][0], "UninstallString")
        EndIf
        $i += 1
    WEnd
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...