Popular Post Danyfirex Posted September 6, 2014 Popular Post Share Posted September 6, 2014 (edited) A simple example of listing installed applications using ObjCreateInterface. Update. 10/09/2014 expandcollapse popup;Danyfirex 06/09/2014 #include <Array.au3> Opt("MustDeclareVars", 1) 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 Local $aArray = GetInstalledApps(BitOR($AIM_DISPLAYNAME, $AIM_INSTALLDATE)) _ArrayDisplay($aArray, "GetInstalledApps", Default, Default, Default, "NAME|INSTALLDATE") $aArray = GetInstalledApps(BitOR($AIM_DISPLAYNAME, $AIM_UPDATEINFOURL)) _ArrayDisplay($aArray, "GetInstalledApps", Default, Default, Default, "DISPLAYNAME|UPDATEINFOURL") $aArray = GetInstalledApps(BitOR($AIM_DISPLAYNAME, $AIM_INSTALLDATE, $AIM_INSTALLLOCATION)) _ArrayDisplay($aArray, "GetInstalledApps", Default, Default, Default, "DISPLAYNAME|INSTALLLOCATION|INSTALLDATE") Func GetInstalledApps($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 Saludos Edited September 10, 2014 by Danyfirex jaberwacky, LarsJ, JohnOne and 5 others 8 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
jaberwacky Posted September 7, 2014 Share Posted September 7, 2014 Sweet. Been thinking about doing this for awhile, but I never got around to it. When I install or uninstall programs, I like to keep the exes in Installed and Uninstalled folders. This is so that I don't have to hunt all over the net to find programs to reinstall everything after a fresh format. This will help me make a script which automates this process for me. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Rich071 Posted September 7, 2014 Share Posted September 7, 2014 Excellent work. Thanks for sharing. I also keep the old versions of installed programs. There are a few companies, that remove the older versions, when they release a new one. I guess, that's one way, to get you to upgrade. I like this better than Belarc Advisor, since your list is by program name and matches the Windows uninstall list instead of Company Name. You have a bunch of "No Company Name's" and then the program name in their list and they get all the sub programs in the sub folders, which I prefer just what was actually installed. All I need is the main installation info. This has given me some ideas to expand on this, like comparing computers to see which apps are not updated on both machines Even possibly scanning select folders for portable apps. I have portable apps on a separate partition that are shared with different Window installs on the same machine. One update, updates all. Makes it a lot easier to maintain. I haven't looked at the code yet, but I did notice a minor issue. If the version is actually blank, it's getting populated with the same version of the previous entry. You can tell the difference by looking at the Windows uninstall list, that also have a blank versions, but shows a different version in the.name. It would be nice if they would fill out the info the way it was intended. Like I said, Excellent and thanks again fro sharing. Link to comment Share on other sites More sharing options...
qwert Posted September 7, 2014 Share Posted September 7, 2014 This is very useful. Thanks. Can someone show the mods necessary to add installed date to the displayed array? I made an attempt with: Global Const $AIM_INSTALLDATE = 0x00001000 : $aArray = GetInstalledApps(BitOR($AIM_DISPLAYNAME, $AIM_VERSION, $AIM_PUBLISHER, $AIM_INSTALLDATE)) _ArrayDisplay($aArray,"GetInstalledApps",Default, Default, Default, "Name|VERSION|PUBLISHER|Install Date") The date column displays, but the dates are all 0. Link to comment Share on other sites More sharing options...
jaberwacky Posted September 7, 2014 Share Posted September 7, 2014 MSDN has a different struct for the AppInfoData struct. Theirs doesn't have psvPublisher and has psvLanguage twice. What in the world is going on here? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
wakillon Posted September 7, 2014 Share Posted September 7, 2014 I just try your example, and I have some doubt about it working... may be a problem for get versions and publisher ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Danyfirex Posted September 7, 2014 Author Share Posted September 7, 2014 (edited) The example work same as Control Panel/Add/Remove Programs. for some reason (I don't know) Only work with $AIM_DISPLAYNAME, $AIM_VERSION,$AIM_PUBLISHER flags. (just tested on window 7 x86). @jaberwacky I glad it helps. @ Rich071 I'll look into. @qwert for some reason only work with that three flags that I show. @wakillon I foget to clean the structure. I'll fix it in a while. saludos Edited September 7, 2014 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
JScript Posted September 7, 2014 Share Posted September 7, 2014 @DanyfirexAutoIt3Wrapper v.2.2.0.3SciTE v.3.4.1.0Keyboard:00010416OS:WIN_81/ CPU:X64 OS:X64Environment(Language:0416)Result:JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Danyfirex Posted September 7, 2014 Author Share Posted September 7, 2014 @JScript Thank you. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
JScript Posted September 7, 2014 Share Posted September 7, 2014 @DanyfirexYour program shows the publisher of utorrent as the Jos van der Zande, but "Add and Remove Programs" windows shows this:JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Danyfirex Posted September 7, 2014 Author Share Posted September 7, 2014 @Js Try the code again. I updated it. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
JScript Posted September 7, 2014 Share Posted September 7, 2014 @DanyfirexNow it worked, but instead of 0 could be an empty string?JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Danyfirex Posted September 7, 2014 Author Share Posted September 7, 2014 (edited) Okey Js. I'll fix it. thank you. Update. Edited September 7, 2014 by Danyfirex JScript 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
wakillon Posted September 7, 2014 Share Posted September 7, 2014 Your last version is better, but some versions were not found... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Danyfirex Posted September 7, 2014 Author Share Posted September 7, 2014 @wakillon look in Add and Remove Programs I'm sure it either returns the value. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
JScript Posted September 7, 2014 Share Posted September 7, 2014 (edited) @DanyfirexNow work!@wakillonYour signature breaks the forum interface: '>JS Edited September 7, 2014 by JScript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
wakillon Posted September 7, 2014 Share Posted September 7, 2014 @wakillon Your signature breaks the forum interface: '> I do not have this problem. What's your browser ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Danyfirex Posted September 7, 2014 Author Share Posted September 7, 2014 me neither. I have Google. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
JScript Posted September 7, 2014 Share Posted September 7, 2014 @wakillonFirefox 31.0 - I guess I better open another topic for not escape the current focus!JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
wakillon Posted September 7, 2014 Share Posted September 7, 2014 Just click on the little grey cross for access to a menu and then ignore my signature. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now