MadaraUchiha Posted November 12, 2013 Share Posted November 12, 2013 Hello guys, I am a bit confused. Because, I like to list the installed applications on my computer. After some research I found out, that I can grab it from the Registry: Const $NODE = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $i = 1 While 1 $var = RegEnumKey($NODE, $i) If @error <> 0 then ExitLoop MsgBox(4096, "#" & $i, $var) $i+=1 WEnd That works, but there is on problem. Application like Windows Messenger or Windows Moviemaker appear like 50 times. So In the end the list is like 500 applications large? I want only a list like you can find it in the Systemcontrol -> SoftwareList In this list, these Microsoft apps won't appear multiple times. How can I fix it so I get the same list like here? If I try it with WMI, the result is also the same, the microsoft apps appear way to often? Any ideas? Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 12, 2013 Share Posted November 12, 2013 Do those registry keys actually exist? Because your example works fine for me and doesn't do that. I'd do the return into an array, sort it by name and come up with a caching scheme to remove duplicates. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 12, 2013 Share Posted November 12, 2013 _ArrayUnique should help with that. 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 GudeHow 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 More sharing options...
MadaraUchiha Posted November 12, 2013 Author Share Posted November 12, 2013 (edited) Hm, I am not sure if filtering this list is the right way... I mean, System Control Center also gets the installed program list from somewhere, without filtering...? I think there is a better way to enumerate all Installed applications. But how? Edited November 12, 2013 by MadaraUchiha Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 12, 2013 Share Posted November 12, 2013 (edited) I think you're assuming that data is readily available. Why do you think it takes time to open the list on machines with a lot of stuff installed? The data is there and it's up to you to use it the way you want. I'd recommend using the uninstall string, if it's available to be modified/uninstalled, chances are it has an uninstall string. Just harvested a couple functions I had written for some software inventory. I sorted it by the uninstall string, wonder if that list looks better for you? You could generate the list based on that field instead instead. Edit again : Looped through the array and deleted values that don't exist for the uninstall string. expandcollapse popup#include <Array.au3> Global $asApplications $asApplications = _PC_GetProgramList(@ComputerName) If Not @error Then _ArraySort($asApplications, 0, 0, 0, 4) For $i = UBound($asApplications) - 1 To 0 Step - 1 If Not StringLen($asApplications[$i][4]) Then _ArrayDelete($asApplications, $i) Endif Next _ArrayDisplay($asApplications) EndIf Func _PC_GetProgramList($sRPC) Local $sRegUninstallPath = "\\" & $sRPC & "\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" Local $asRegKeys, $asSearchKeys, $asInstalledApps[1][1] $asSearchKeys = StringSplit("DisplayName,DisplayVersion,Publisher,UninstallString,QuietUninstallString,URLInfoAbout", ",") $asRegKeys = _PC_GetRegistryKeys($sRegUninstallPath) If Not @error Then ReDim $asInstalledApps[$asRegKeys[0]][$asSearchKeys[0] + 1] For $i = 1 To $asRegKeys[0] $asInstalledApps[$i - 1][0] = $asRegKeys[$i] For $n = 1 To $asSearchKeys[0] $asInstalledApps[$i - 1][$n] = StringStripWS(RegRead($sRegUninstallPath & $asRegKeys[$i], $asSearchKeys[$n]), 3) Next Next Return $asInstalledApps Else Return SetError(1,0,0) ; Error 1 - unable to read registry. EndIf EndFunc Func _PC_GetRegistryKeys($sRegPath) Local $var, $sResult Local $i = 1 While 1 $var = RegEnumKey($sRegPath, $i) If @error Then If @error <> -1 Then SetError(1) Return 0 EndIf ExitLoop EndIf $sResult &= $var & Chr(128) $i += 1 WEnd Return StringSplit(StringTrimRight($sResult, 1), Chr(128)) EndFunc Edited November 12, 2013 by ZacUSNYR 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