Jump to content

Search for a Program in Add/Remove Programs List


Recommended Posts

In order for program installation scrip to run correctly, I have to check whether that program is already installed on the system before I do so.

Basically, I wanted to check in Add/Remove Programs for a Program that's installed and return 1 for true or return 2 for false.

If true Then skip the installation proccess and jump to Activate the software, else if false then install the software and activate it.

What's the best way to tackle this? Please help as I'm new in this.

Thanks in advance. :">

Dreamzboy

Link to comment
Share on other sites

It's somewhere in Windows registry so RegRead() will be the right command.

EDIT: I saw some script for listing apps from there try to search ...

I found it:

;===============================================================================
; Description:      Returns the Software information in an array.
; Parameter(s):     $aSoftwareInfo - By Reference - Software Information array.
; Requirement(s):   None
; Return Value(s):  On Success - Returns array of Software Information.
;                       $aSoftwareInfo[0][0]   = Number of Software Installed
;                       $aSoftwareInfo[$i][0]  = Name ($i starts at 1)
;                       $aSoftwareInfo[$i][1]  = Version
;                       $aSoftwareInfo[$i][2]  = Publisher
;                       $aSoftwareInfo[$i][3]  = Uninstall String
;                   On Failure - @error = 1 and Returns 0
;                               @extended = 1 - Array contains no information
; Author(s):        Jarvis Stubblefield (support "at" vortexrevolutions "dot" com)
; Note(s):
;===============================================================================
Func _ComputerGetSoftware(ByRef $aSoftwareInfo)
    Local Const $UnInstKey  = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 1
    Dim $aSoftwareInfo[1][4]
    
    While 1
        $AppKey = RegEnumKey($UnInstKey, $i)
        If @error <> 0 Then ExitLoop
        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 += 1
    WEnd
    
    $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
    If $aSoftwareInfo[0][0] < 1 Then
        SetError(1, 1, 0)
    EndIf
EndFunc
Edited by Zedna
Link to comment
Share on other sites

Remember that installed apps do not have to be listed in the add/remove list.

If you know the names of all the apps you are looking for then you are better off to search the registry for references to those apps . In most (not all) cases you will be able to fin a key with a value of installpath or path or something similar. Make a list of those registry entries and check them with your code. Also take a look for a key named installed apps or installedapps. I forget just where it is located.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

It's somewhere in Windows registry so RegRead() will be the right command.

EDIT: I saw some script for listing apps from there try to search ...

I found it:

;===============================================================================
; Description:      Returns the Software information in an array.
; Parameter(s):     $aSoftwareInfo - By Reference - Software Information array.
; Requirement(s):   None
; Return Value(s):  On Success - Returns array of Software Information.
;                       $aSoftwareInfo[0][0]   = Number of Software Installed
;                       $aSoftwareInfo[$i][0]  = Name ($i starts at 1)
;                       $aSoftwareInfo[$i][1]  = Version
;                       $aSoftwareInfo[$i][2]  = Publisher
;                       $aSoftwareInfo[$i][3]  = Uninstall String
;                   On Failure - @error = 1 and Returns 0
;                               @extended = 1 - Array contains no information
; Author(s):        Jarvis Stubblefield (support "at" vortexrevolutions "dot" com)
; Note(s):
;===============================================================================
Func _ComputerGetSoftware(ByRef $aSoftwareInfo)
    Local Const $UnInstKey  = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 1
    Dim $aSoftwareInfo[1][4]
    
    While 1
        $AppKey = RegEnumKey($UnInstKey, $i)
        If @error <> 0 Then ExitLoop
        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 += 1
    WEnd
    
    $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
    If $aSoftwareInfo[0][0] < 1 Then
        SetError(1, 1, 0)
    EndIf
EndFunc

Thanks Zedna.

Now how do you call this function? Say I wanna know if Microsoft Office Professional 2003 is installed on my system or not. Sorry, I just barely understand the language.

Link to comment
Share on other sites

#include <array.au3>

Dim $aSoft[1]

_ComputerGetSoftware($aSoft)
_ArrayDisplay($aSoft,'Instaled Software')

This is what I did but when I try to run the program this is the error message that I get:

C:\PROGRA~1\AutoIt3\Include\array.au3 (175) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$sMsg = $sMsg & "[" & $iCounter & "] = " & StringStripCR($avArray[$iCounter]) & @CR

$sMsg = $sMsg & "[" & $iCounter & "] = " & StringStripCR(^ ERROR

It's obvious that the problems lie within the Array Library, unless my code is incorrect.

Thanks!

Link to comment
Share on other sites

Thanks Zedna.

Now how do you call this function? Say I wanna know if Microsoft Office Professional 2003 is installed on my system or not. Sorry, I just barely understand the language.

Here's a program I wrote to check / erase Office Keys.. You can use the function to check for an office 2003 installation!

#NoTrayIcon

#include <GUIConstants.au3>

GUICreate("Office-Key-Cleaner", 353, 175)

$2007button = GUICtrlCreateButton("Flush Office 2007 Key", 235, 115)

$2003button = GUICtrlCreateButton("Flush Office 2003 Key", 115, 115)

$XPbutton = GUICtrlCreateButton("Flush Office XP Key",5,115)

$Exitbutton = GUICtrlCreateButton("Exit", 98, 145, 150)

GUICtrlCreateLabel( ".::~Neo~::.", 153, 0)

GUICtrlCreateLabel( "www.LiquidPerceptions.com", 110,15)

GUICtrlCreateLabel( " This program will flush your Microsoft Office© key code so you can" & @CRLF & "re-enter it. This is not a key generator, and I don't want it to be.", 5, 60)

GUISetState(@SW_SHOW)

Do

$msg = GUIGetMsg()

sleep(50)

Select

Case $msg = $XPbutton

CheckXP()

Case $msg = $2003button

Check2003()

Case $msg = $2007button

Check2007()

Case $msg = $Exitbutton

Exit

Case $msg = $GUI_EVENT_CLOSE

Exit

EndSelect

Until 1 = 0

Func CheckXP()

$i= 1

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration", $i)

If @error <> 0 then

MsgBox(48, "Error:", "We have detected either Office XP is not installed, or you are not registered!")

ElseIf @error = 0 Then

EraseXP()

EndIf

EndFunc

Func EraseXP()

$i= 1

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration", $i)

MsgBox(4096, "Your GUID Is:", $var)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration\" & $var , "DigitalProductID", "REG_BINARY", "")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration\" & $var , "ProductID", "REG_BINARY", "")

MsgBox(4096,"Successfull!", "Office XP Key successfully flushed!")

EndFunc

Func Check2003()

$i= 1

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration", $i)

If @error <> 0 then

MsgBox(48, "Error:", "We have detected either Office 2003 is not installed, or you are not registered!")

ElseIf @error = 0 Then

Erase2003()

EndIf

EndFunc

Func Erase2003()

$i= 1

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration", $i)

MsgBox(4096, "Your GUID Is:", $var)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $var , "DigitalProductID", "REG_BINARY", "")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $var , "ProductID", "REG_BINARY", "")

MsgBox(4096,"Successfull!", "Office 2003 Key successfully flushed!")

EndFunc

Func Check2007()

$i= 1

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration", $i)

If @error <> 0 then

MsgBox(48, "Error:", "We have detected either Office 2007 is not installed, or you are not registered!")

ElseIf @error = 0 Then

Erase2007()

EndIf

EndFunc

Func Erase2007()

$i= 1

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration", $i)

MsgBox(4096, "Your GUID Is:", $var)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration\" & $var , "DigitalProductID", "REG_BINARY", "")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Registration\" & $var , "ProductID", "REG_BINARY", "")

MsgBox(4096,"Successfull!", "Office 2007 Key successfully flushed!")

EndFunc

"I'm not here to make decisions, I'm here to make a difference"

Link to comment
Share on other sites

Hi Liquid,

Thanks for the help.

I use your function and so far it works far better than all the other I have tried. What i don't understand is that when u use

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\[b]Microsoft\Office\10.0\Registration[/b]", $i)oÝ÷ ÙhZ¶+"µìZrÙr¶­Eèé{(¬$x¢°^q«¬{^kçm¢ë¶¬jg¥¢~æÉ*·«x(^rH­¶¸ êí+,µ«^éí~æÉÊy·¥£èmëf{
診·(uë0¢¹,)iÈZ®hî²Ù¢è¬mvç­¢Ø^}§-¶­#oyÈZ¶¡Æ­è^­ä^I².Ùh¢F­6bqâÙ÷ö×!jxªê-Iç.­àNÚÊè²ímçºÇ­µìmj·¢®·¥zö§´¥£¬'(u殶­se6V7W&T5%B ¤gVæ26V7W&T5%B¢b33c¶Ò¢b33c·f"Ò&VtVçVÔ¶WgV÷C´´UôÄô4ÅôÔ4äRb3#µ4ôeEt$Rb3#µ¶%ÕfäG¶Rb3#µ6V7W&T5%Bb3#´Æ6Vç6U²ö%ÒgV÷C²Âb33c¶¤bW'&÷"fÇC²fwC²FVà¤×6t&÷CÂgV÷C´W'&÷#¢gV÷C²ÂgV÷CµvRfRFWFV7FVBVFW"6V7W&T5%B2æ÷Bç7FÆÆVBÂ÷"÷R&Ræ÷B&Vv7FW&VBb333²gV÷C²¤VÇ6TbW'&÷"ÒFVà¤×6t&÷ÂgV÷C²gV÷C²ÂgV÷Cµ77FVÒFWFV7FVB6V7W&T5%B2Ç&VGç7FÆÆVBgV÷C²¤VæD`¤VæDgVæ0oÝ÷ Ù8^ºè¬Ç¬±¨jëh×6
MsgBox(48, "Error:", "We have detected either SecureCRT is not installed, or you are not registered!")

Another step closer to final result. :) You guys are great and I appreciate both of you for sharing your knowledge with me.

Zedna,

I'm not saying your method is a waste, it is useful to me. I'll look into that method when I have time. Thank YOU.

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