Jump to content
Sign in to follow this  
beato

Searching for file that exists in different locations

Recommended Posts

beato

I am looking for some help with the following search method. Simple silent uninstall routine, but the problem is that the "uninstaller" location is different on the clients => \Application 3.0 or 3.5 or 7.8 etc..

How can I search for the "unins000.exe " using a wildcard for example to search through the different directory versions, or another method to find it and then run it?

Thanks.

If FileExists("C:\Program Files\Application name\Application 3.0\unins000.exe") Then
        Run("C:\Program Files\Application name\Application 3.0\unins000.exe /SILENT")
Edited by beato

Share this post


Link to post
Share on other sites
Authenticity

Is the whole installation supposed to be within "Program Files" folder and you don't sure how the folder might be called?

Share this post


Link to post
Share on other sites
rudi

Hi.

If this installation is following the windows standards, it will leave it's uninstall string in HKLM\Software\Microsoft\Windows\CurrentVersion\uninstall\<somekey>.

This should help you to check out:

#include <array.au3> ; required just for the _arraydisplay()

$UninstThisOne = "Moldflow"
$i = 1
Dim $ProdArr[1] = [0]

While 1
    $UnInst = RegEnumKey("hklm\Software\microsoft\windows\currentversion\uninstall", $i)
    If @error Then ExitLoop
    _ArrayAdd($ProdArr, $UnInst)
    $i += 1
WEnd
$ProdArr[0] = UBound($ProdArr) - 1
_ArrayDisplay($ProdArr)

For $i = 1 To $ProdArr[0]
    $NextProd = RegRead("hklm\Software\microsoft\windows\currentversion\uninstall\" & $ProdArr[$i], "DisplayName")
    If StringInStr($NextProd, $UninstThisOne) Then ; this should be the right one.
        $NextUIstring = RegRead("hklm\Software\microsoft\windows\currentversion\uninstall\" & $ProdArr[$i], "UninstallString")

        ;MsgBox features: Title=No, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=Question, Timeout=30 ss, Miscellaneous=Top-most attribute
        If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
        $iMsgBoxAnswer = MsgBox(262436, "Prove uninstall", "Do you *REALLY* want to uninstall " & $NextProd & "?" & @LF & _
                "Uninstall String = '" & $NextUIstring & "'", 30)
        Select
            Case $iMsgBoxAnswer = 6 ;Yes
                $result = RunWait($NextUIstring)
                ; check the result, if you like
                ; ...
            Case $iMsgBoxAnswer = 7 ;No

            Case $iMsgBoxAnswer = -1 ;Timeout
        EndSelect
    EndIf
Next

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites
beato

Hi.

If this installation is following the windows standards, it will leave it's uninstall string in HKLM\Software\Microsoft\Windows\CurrentVersion\uninstall\<somekey>.

This should help you to check out:

#include <array.au3> ; required just for the _arraydisplay()

$UninstThisOne = "Moldflow"
$i = 1
Dim $ProdArr[1] = [0]

While 1
    $UnInst = RegEnumKey("hklm\Software\microsoft\windows\currentversion\uninstall", $i)
    If @error Then ExitLoop
    _ArrayAdd($ProdArr, $UnInst)
    $i += 1
WEnd
$ProdArr[0] = UBound($ProdArr) - 1
_ArrayDisplay($ProdArr)

For $i = 1 To $ProdArr[0]
    $NextProd = RegRead("hklm\Software\microsoft\windows\currentversion\uninstall\" & $ProdArr[$i], "DisplayName")
    If StringInStr($NextProd, $UninstThisOne) Then ; this should be the right one.
        $NextUIstring = RegRead("hklm\Software\microsoft\windows\currentversion\uninstall\" & $ProdArr[$i], "UninstallString")

        ;MsgBox features: Title=No, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=Question, Timeout=30 ss, Miscellaneous=Top-most attribute
        If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
        $iMsgBoxAnswer = MsgBox(262436, "Prove uninstall", "Do you *REALLY* want to uninstall " & $NextProd & "?" & @LF & _
                "Uninstall String = '" & $NextUIstring & "'", 30)
        Select
            Case $iMsgBoxAnswer = 6 ;Yes
                $result = RunWait($NextUIstring)
                ; check the result, if you like
                ; ...
            Case $iMsgBoxAnswer = 7 ;No

            Case $iMsgBoxAnswer = -1 ;Timeout
        EndSelect
    EndIf
Next

Regards, Rudi.

:) Thanks! I use the uninstall hive for other routines but didn't think of it in this way (not that I would have came up with what you did by any means). I will tweak it to remove the message box and see what happens. Again, thank you very much Rudi.

Share this post


Link to post
Share on other sites
beato

Is the whole installation supposed to be within "Program Files" folder and you don't sure how the folder might be called?

Correct, was trying to figure away to search taking into consideration the different install paths etc.. I think Rudi provided what I am looking for.

Thanks

Share this post


Link to post
Share on other sites
rudi

:) Thanks! I use the uninstall hive for other routines but didn't think of it in this way (not that I would have came up with what you did by any means). I will tweak it to remove the message box and see what happens. Again, thank you very much Rudi.

Glad to help.

If you want to do it 100% silently take care to proove, that your *REALLY* *ONLY* uninstall just the product you want to kick. And take care to catch possibly installed, different versions of your Prod, and to follow the correct uninstall order :lmao:

Have a look at #RequireAdmin, if needed.

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites
beato

Glad to help.

If you want to do it 100% silently take care to proove, that your *REALLY* *ONLY* uninstall just the product you want to kick. And take care to catch possibly installed, different versions of your Prod, and to follow the correct uninstall order :)

Have a look at #RequireAdmin, if needed.

Regards, Rudi.

Thanks. Hmmm, I have been looking at this for awhile and am having trouble - I do want to do this completely silently. There are two products under the title "MoldFlow" but they both have two completely different uninstall strings (from the Uninstall hive). Somehow (I think) there needs to be a "StringReplace" to reference the "/SILENT and the "-NoQuestion" options that will make this run silently - see exact uninstall commands from the reg uninstall hive below.

One is:

C:\Program Files\Moldflow\Plastics Advisers 7.3\unins000.exe /SILENT

The second is:

RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\PROFES~1\RunTime\09\01\Intel32\Ctor.dll,LaunchSetup "C:\Program Files\InstallShield Installation Information\{C8B442A2-9715-4E6F-994F-0011AC66D8CD}\setup.exe" -l0x9 -uninst -NoQuestion'

It seems that something along the lines of:

$result = RunWait(StringReplace($NextUIstring,"("," /SILENT("),"")

in the message box area is needed? I dunno. In the end it should find any and all instances of "Moldflow" and then run what's specified in the Uninstall hive but with the /SILENT and -NoQuestions. These two switches are not in the Uninstall hive but are the sort of the equivilent of 'MsiExec.exe /X", a hidden switch if you will.

Any thoughts appreciated. Thanks

Edited by beato

Share this post


Link to post
Share on other sites
rudi

Thanks. Hmmm, I have been looking at this for awhile and am having trouble - I do want to do this completely silently.

[snip]

One is:

C:\Program Files\Moldflow\Plastics Advisers 7.3\unins000.exe /SILENT

The second is:

RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\PROFES~1\RunTime\09\01\Intel32\Ctor.dll,LaunchSetup "C:\Program Files\InstallShield Installation Information\{C8B442A2-9715-4E6F-994F-0011AC66D8CD}\setup.exe" -l0x9 -uninst -NoQuestion'

[snip]

in the message box area is needed? I dunno.

Sorry, I miss, what you are asking here. If the Msgbox is required? No. Just kick the whole code for the MsgBox :)

Perhaps you might want to read up the help files (just quickly touch all the topics without reading them in detail), and search for autoit123?

In the end it should find any and all instances of "Moldflow" and then run what's specified in the Uninstall hive but with the /SILENT and -NoQuestions. These two switches are not in the Uninstall hive but are the sort of the equivilent of 'MsiExec.exe /X", a hidden switch if you will.

if StringInStr($NextUIstring,"rundll32") Then
    if not StringInStr($NextUIstring," -noquestion") Then
        $NextUIstring &= " -NoQuestion"
    EndIf
Else
    if StringInStr($NextUIstring,"unins000.exe") Then
        if not StringInStr($NextUIstring," /silent") Then
            $NextUIstring &= " /SILENT"
        EndIf
    EndIf
Else
    MsgBox(48,"Warning","Expected  blah blah ... not found")
    ; uninstall without /silent option
EndIf

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites
beato

Sorry, I miss, what you are asking here. If the Msgbox is required? No. Just kick the whole code for the MsgBox :)

Perhaps you might want to read up the help files (just quickly touch all the topics without reading them in detail), and search for autoit123?

if StringInStr($NextUIstring,"rundll32") Then
    if not StringInStr($NextUIstring," -noquestion") Then
        $NextUIstring &= " -NoQuestion"
    EndIf
Else
    if StringInStr($NextUIstring,"unins000.exe") Then
        if not StringInStr($NextUIstring," /silent") Then
            $NextUIstring &= " /SILENT"
        EndIf
    EndIf
Else
    MsgBox(48,"Warning","Expected  blah blah ... not found")
    ; uninstall without /silent option
EndIf

Regards, Rudi.

Thanks Rudi.

Share this post


Link to post
Share on other sites
rudi

Thanks Rudi.

You are welcome.

Did I guess the intention of your question correctly?

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.