Sign in to follow this  
Followers 0
AntiVirusGuy

uninstall any version not the exact

11 posts in this topic

#1 ·  Posted (edited)

How would I uninstall any version of autoit. In other words a "display Name" that only contained the string of "autoit"

Don't get me wrong I would never uninstall autoit but it made a good example :whistle:

I am a little sketchy with functions (I am a begginer) so please be percise, Thank you all for your help.

; see the name of program in Add/Remove? Put it here \/

$MYAPP = "AutoIt"

$UNINSTALLSTRING = GetUninstallString($MYAPP)

If Not @error Then Run($UNINSTALLSTRING)

Func GetUninstallString($app)

$key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"

$i = 0

While 1

$i = $i + 1

$subkey = RegEnumKey($key,$i)

If @error Then ExitLoop

$displayname = RegRead($key & "\" & $subkey,"DisplayName")

If @error Then ContinueLoop

If $displayname == $app Then

Return RegRead($key & "\" & $subkey,"UninstallString")

EndIf

WEnd

SetError(1)

Return ""

EndFunc

Edited by ssebrownatcolby

Share this post


Link to post
Share on other sites



I am not exactly sure what you are looking for. If you want to read the display name, then why can't you specifically compare the string?

Share this post


Link to post
Share on other sites

I do not know what the display name will be. In other words I want to find all "autoit" "autoit 3.1.0" and "autoit 3.1.1" or even autoit "2.9.0"

I am not exactly sure what you are looking for. If you want to read the display name, then why can't you specifically compare the string?

Share this post


Link to post
Share on other sites

To match any string containing autoit, one can simply use:

If StringInStr($variable,"autoit") then 
  ; go do stuff
else
 ; didn't find it.
endif

Refer to the StringInStr() doc.

The doc guys have done a GREAT job w/ the docs....You need to read through the manual at least once, just so you know what features you have available.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I read it inside and out and have been struggling and I am still confused by your suggestion I am not a programmer and do not understand how a function works how would I put your suggestion in my script I just can't make it go

$MYAPP = "AutoIt"

$UNINSTALLSTRING = GetUninstallString($MYAPP)

If Not @error Then Run($UNINSTALLSTRING)

Func GetUninstallString($app)

$key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"

$i = 0

While 1

$i = $i + 1

$subkey = RegEnumKey($key,$i)

If @error Then ExitLoop

$displayname = RegRead($key & "\" & $subkey,"DisplayName")

If @error Then ContinueLoop

If $displayname == $app Then

Return RegRead($key & "\" & $subkey,"UninstallString")

EndIf

WEnd

SetError(1)

Return ""

EndFunc

To match any string containing autoit, one can simply use:

If StringInStr($variable,"autoit") then 
; go do stuff
else
; didn't find it.
endif

Refer to the StringInStr() doc.

The doc guys have done a GREAT job w/ the docs....You need to read through the manual at least once, just so you know what features you have available.

Edited by ssebrownatcolby

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You should use Code Tags!!... as per my suggestion and some others... StringInStr() is the way to go... you only want to do something when it's found right?

$MYAPP = "AutoIt"
$UNINSTALLSTRING = GetUninstallString($MYAPP)
MsgBox(64, 'Info:', $UNINSTALLSTRING)
If Not @error Then Run($UNINSTALLSTRING)
Func GetUninstallString($app)
    Local $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    $i = 0
    While 1
        $i += 1
        Local $subkey = RegEnumKey($key, $i)
        If @error Then ExitLoop
        Local $displayname = RegRead($key & "\" & $subkey,"DisplayName")
        If StringInStr($displayname, $app) Then Return $displayname
    WEnd
    Return SetError(1, 0, 0)
EndFuncoÝ÷ Øhm­ë)¢wm¢Ê&zò¢êí·vÆÞq«¬zíç(uëZØb   ÊÊ.Û"ºØ­$²X¤zÈb·^*.®Úòx-¢·v+Dv+@~׫$x¶Ø^FéíêÞ!© ¢)ඬ²éÊ·ö·rÛ¥¢"è®Ê&zØb    bëaÆ®¶­sbb33c´ÕÒgV÷C´WFôBgV÷C°¢b33cµTäå5DÄÅ5E$ärÒvWEVæç7FÆÅ7G&ærb33c´Õ¤×6t&÷cBÂb33´æfó¢b33²Âb33cµTäå5DÄÅ5E$är£´bæ÷BW'&÷"FVâ'Vâb33cµTäå5DÄÅ5E$är¤gVæ2vWEVæç7FÆÅ7G&ærb33c¶¢Æö6Âb33c¶¶WÒgV÷C´´ÄÒb3#µ6ögGv&Rb3#´Ö7&÷6ögBb3#µvæF÷w2b3#´7W'&VçEfW'6öâb3#µVæç7FÆÂgV÷C°¢b33c¶Ò¢vÆR¢b33c¶³Ò¢Æö6Âb33c·7V&¶WÒ&VtVçVÔ¶Wb33c¶¶WÂb33c¶¢bW'&÷"FVâWDÆö÷¢Æö6Âb33c¶F7ÆæÖRÒ&Vu&VBb33c¶¶WfײgV÷C²b3#²gV÷C²fײb33c·7V&¶WÂgV÷C´F7ÆæÖRgV÷C²¢b7G&ætå7G"b33c¶F7ÆæÖRÂb33c¶FVâ&WGW&â&Vu&VBb33c¶¶Wfײb33²b3#²b33²fײb33c·7V&¶WÂb33µVæç7FÆÅ7G&ærb33²¢tVæ@¢&WGW&â6WDW'&÷"¤VæDgVæ

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You should use Code Tags!!... as per my suggestion and some others... StringInStr() is the way to go... you only want to do something when it's found right?

$MYAPP = "AutoIt"
$UNINSTALLSTRING = GetUninstallString($MYAPP)
MsgBox(64, 'Info:', $UNINSTALLSTRING)
If Not @error Then Run($UNINSTALLSTRING)
Func GetUninstallString($app)
    Local $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    $i = 0
    While 1
        $i += 1
        Local $subkey = RegEnumKey($key, $i)
        If @error Then ExitLoop
        Local $displayname = RegRead($key & "\" & $subkey,"DisplayName")
        If StringInStr($displayname, $app) Then Return $displayname
    WEnd
    Return SetError(1, 0, 0)
EndFuncoÝ÷ Øhm­ë)¢wm¢Ê&zò¢êí·vÆÞq«¬zíç(uëZØb   ÊÊ.Û"ºØ­$²X¤zÈb·^*.®Úòx-¢·v+Dv+@~׫$x¶Ø^FéíêÞ!© ¢)ඬ²éÊ·ö·rÛ¥¢"è®Ê&zØb    bëaÆ®¶­sbb33c´ÕÒgV÷C´WFôBgV÷C°¢b33cµTäå5DÄÅ5E$ärÒvWEVæç7FÆÅ7G&ærb33c´Õ¤×6t&÷cBÂb33´æfó¢b33²Âb33cµTäå5DÄÅ5E$är£´bæ÷BW'&÷"FVâ'Vâb33cµTäå5DÄÅ5E$är¤gVæ2vWEVæç7FÆÅ7G&ærb33c¶¢Æö6Âb33c¶¶WÒgV÷C´´ÄÒb3#µ6ögGv&Rb3#´Ö7&÷6ögBb3#µvæF÷w2b3#´7W'&VçEfW'6öâb3#µVæç7FÆÂgV÷C°¢b33c¶Ò¢vÆR¢b33c¶³Ò¢Æö6Âb33c·7V&¶WÒ&VtVçVÔ¶Wb33c¶¶WÂb33c¶¢bW'&÷"FVâWDÆö÷¢Æö6Âb33c¶F7ÆæÖRÒ&Vu&VBb33c¶¶WfײgV÷C²b3#²gV÷C²fײb33c·7V&¶WÂgV÷C´F7ÆæÖRgV÷C²¢b7G&ætå7G"b33c¶F7ÆæÖRÂb33c¶FVâ&WGW&â&Vu&VBb33c¶¶Wfײb33²b3#²b33²fײb33c·7V&¶WÂb33µVæç7FÆÅ7G&ærb33²¢tVæ@¢&WGW&â6WDW'&÷"¤VæDgVæ

what code tag????

I am getting an error when it tries to run the uninstaller. I fixed it thank you so much for your help and patients. Where can I learn more about all this I read the docs but they do not make sense ....no programming background

Edited by ssebrownatcolby

Share this post


Link to post
Share on other sites

what code tag????

I am getting an error when it tries to run the uninstaller. I fixed it thank you so much for your help and patients. Where can I learn more about all this I read the docs but they do not make sense ....no programming background

Before Code = [ Code]

After Code = [ /Code]

Both without spaces when you are going to show your code that you need help with or want to show others.

Tutorials:

http://www.autoitscript.com/forum/index.ph...l=lxp++tutorial

http://www.autoitscript.com/forum/index.php?showtopic=21048


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks for all your help. One last little thing. It stops after the first instance.

Any way to make it keep searching until it comes up empty?

I assume to look for multiple searches for multiple products just duplicate the code over and over or is there a way to specify $MYAPP = "microsoft" and "Autoit"

Thanks again for all the help

Share this post


Link to post
Share on other sites

Wow man... what have you "tried"?

$MYAPP = "AutoIt"
$UNINSTALLSTRING = GetUninstallString($MYAPP)
If IsArray($UNINSTALLSTRING) Then
    For $iCount = 1 To UBound($UNINSTALLSTRING) - 1
        MsgBox(64, 'Info:', $UNINSTALLSTRING[$iCount])
        ;If Not @error Then Run($UNINSTALLSTRING)
    Next
EndIf

Func GetUninstallString($app)
    Local $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 0, $sHold
    While 1
        $i += 1
        Local $subkey = RegEnumKey($key, $i)
        If @error Then ExitLoop
        Local $displayname = RegRead($key & "\" & $subkey,"DisplayName")
        If StringInStr($displayname, $app) Then
            $sHold &= RegRead($key & '\' & $subkey, 'UninstallString') & @LF
        EndIf
    WEnd
    Return StringSplit(StringTrimRight($sHold, 1), @LF)
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

again Thank you

Wow man... what have you "tried"?

$MYAPP = "AutoIt"
$UNINSTALLSTRING = GetUninstallString($MYAPP)
If IsArray($UNINSTALLSTRING) Then
    For $iCount = 1 To UBound($UNINSTALLSTRING) - 1
        MsgBox(64, 'Info:', $UNINSTALLSTRING[$iCount])
        ;If Not @error Then Run($UNINSTALLSTRING)
    Next
EndIf

Func GetUninstallString($app)
    Local $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 0, $sHold
    While 1
        $i += 1
        Local $subkey = RegEnumKey($key, $i)
        If @error Then ExitLoop
        Local $displayname = RegRead($key & "\" & $subkey,"DisplayName")
        If StringInStr($displayname, $app) Then
            $sHold &= RegRead($key & '\' & $subkey, 'UninstallString') & @LF
        EndIf
    WEnd
    Return StringSplit(StringTrimRight($sHold, 1), @LF)
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0