Jump to content

Call This Be Done?


Recommended Posts

Is it possible to pick or identify a program item in the winXp's "add or remove program"? If so how?

The items do not show up using autoit window inf and all the items look the same to it. I know you can

use the msi command but some programs have different MSIs but are identified the same in "add or remove

program" so to cover the different versions I want to remove it using "add or remove program" window.

Thanks

Link to comment
Share on other sites

Why Add / Remove when you can do it direct.

; Enter Displayname as parameter
$displayname = 'VMware Workstation'

$command = _UninstallString($displayname)
Func _UninstallString($displayname)
    Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    For $i = 1 To 1000
        $key_sub = RegEnumKey($key_main, $i)
        If @error Then ExitLoop
        If RegRead($key_main & '\' & $key_sub, 'DisplayName') = $displayname Then
            $uninstallstring = RegRead($key_main & '\' & $key_sub, 'UninstallString')
            If $uninstallstring = '' Or @error Then ContinueLoop
            Return $uninstallstring
        EndIf
    Next
    MsgBox(0, 'UninstallString', 'Not found')
EndFunc

RunWait($command)
; Automate the rest
Link to comment
Share on other sites

Well two things, I trying to modify Office suite ...

1. I'm not trying to remove a program but i'm trying to add features through the "add and remove".

2. Apparently there are multiple msi package names in the company that I haven't even begun to look for. But, they all have the same representation in the "add and remove" console. So, I figure if I can script in to the "add and remove" area and start the msi process there I will not have to worry about the different versions of msi in the system.

Sorry I should have given you more details

Any thoughts?

Thanks

Link to comment
Share on other sites

  • Moderators

I guess I should but I was hoping to do it this way so I can cover other programs too.

Well I modified the code from MHz and came up with this. It is the same as clicking the "Change" button in Add & Remove Programs.

; Enter Displayname as parameter
$displayname = 'Microsoft Office'

$command = _Modify($displayname)

Func _Modify($displayname)
    Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    For $i = 1 To 1000
        $key_sub = RegEnumKey($key_main, $i)
        If @error Then ExitLoop
        If StringInStr(RegRead($key_main & '\' & $key_sub, 'DisplayName'), $displayname) Then
            $ModifyPath = RegRead($key_main & '\' & $key_sub, 'ModifyPath')
            If $ModifyPath = '' Or @error Then
                ContinueLoop
            Else
                Return $ModifyPath
                ExitLoop
            EndIf
        EndIf
    Next
EndFunc  ;==>_Modify

Run($command)
; Automate the rest
Link to comment
Share on other sites

  • Moderators

I do not know how you did that, but it is slick!

Thanks so much!

Glad I could help, but I want you to understand how it works. I did my best to add comments to the script explaining what each part did.

; Provides a displayname to search for
$displayname = 'Microsoft Office'
; Runs the function and captures the return for later use
$command = _Modify($displayname)
; Function that searches the Uninstall Key for the specified displayname
Func _Modify($displayname)
; Sets the key to search in
    Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    For $i = 1 To 1000
    ; Enumerates each key under "Uninstall"
        $key_sub = RegEnumKey($key_main, $i)
    ; Stops the loop if no more keys exist
        If @error Then ExitLoop
    ; Looks for the specified displayname string in the current keys DisplayName value
        If StringInStr(RegRead($key_main & '\' & $key_sub, 'DisplayName'), $displayname) Then
        ; If the previous was successful then we grab the "ModifyPath" value from the current key
            $ModifyPath = RegRead($key_main & '\' & $key_sub, 'ModifyPath')
        ; If the "ModifyPath" does not exist or is blank we keep searching
            If $ModifyPath = '' Or @error Then
                ContinueLoop
            Else                
                Return $ModifyPath
                ExitLoop
            EndIf
        EndIf
    Next
EndFunc ;==>_Modify

Run($command)
; Automate the rest
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...