Jump to content

Can't remove temp folder


Recommended Posts

i make silent install and i use this:

$PreviousInstallation = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Registry Mechanic_is1", "InstallLocation")
If StringRight($PreviousInstallation, 1) = '\' Then
$PreviousInstallation = StringTrimRight($PreviousInstallation, 1)
EndIf
If FileExists($PreviousInstallation & "\RegMech.exe") Then
MsgBox(0x40010, "Registry Mechanic 9", "Please uninstall previous version of Registry Mechanic before install the progarm..")
Exit
DirRemove(@AppdataDir & "\Registry Mechanic 9", 1)
EndIf

its not remove "Registry Mechanic 9" because the script process need to close and then remove the folder so i don't know what to do

i want that after or before pressing OK button "Registry Mechanic 9" folder in AppdataDir will be removed

thanks you

Link to comment
Share on other sites


Since I do not know this scripting langauge, I would assume the reason you cant delete folder because it exit before the deletes happens.

If FileExists($PreviousInstallation & "\RegMech.exe") Then

MsgBox(0x40010, "Registry Mechanic 9", "Please uninstall previous version of Registry Mechanic before install the progarm..")

Exit

DirRemove(@AppdataDir & "\Registry Mechanic 9", 1)

EndIf

That the way I read this script perhaps try changing it to this

If FileExists($PreviousInstallation & "\RegMech.exe") Then

MsgBox(0x40010, "Registry Mechanic 9", "Please uninstall previous version of Registry Mechanic before install the progarm..")

DirRemove(@AppdataDir & "\Registry Mechanic 9", 1)

Exit

EndIf

Link to comment
Share on other sites

I'm with GSM here, it appears that you are Exiting within the If FileExists but before the DirRemove is invoked. I don't use AutoIt myself but would expect the end user would click the OK button to close the MsgBox, which would lead in turn to the directory removal you intended, before EndIf was stated.

My best guess is that you actually meant to use Else before Exit

If FileExists($PreviousInstallation & "\RegMech.exe") Then
MsgBox(0x40010, "Registry Mechanic 9", "Please uninstall previous version of Registry Mechanic before install the program..")
Else
Exit
DirRemove(@AppdataDir & "\Registry Mechanic 9", 1)
EndIf

or in the order GSM suggested

If FileExists($PreviousInstallation & "\RegMech.exe") Then
MsgBox(0x40010, "Registry Mechanic 9", "Please uninstall previous version of Registry Mechanic before install the program..")
DirRemove(@AppdataDir & "\Registry Mechanic 9", 1)
Else
Exit
EndIf

That said, I actually think that your installer would be wrong either way. If you want the end user to uninstall the application themselves, then you should also at least afford them the opportunity to decide upon the removal of the Application Data. Your intent currently appears that you're going to remove that folder, (the name of which you've strangely hardcoded) and do so without asking. If the enduser then decides against an uninstall, the data removal would have been to their detriment.

If you really don't care about what the end user wants then I'd also suggest that whilst RegReading that key, you'd also parse the uninstall subkey and actually perform the uninstallation yourself using that value data. Upon the success of that, you'd be in a better position to remove the intended directory without issue.

Link to comment
Share on other sites

its not remove "Registry Mechanic 9" because the script process need to close and then remove the folder so i don't know what to do

i want that after or before pressing OK button "Registry Mechanic 9" folder in AppdataDir will be removed

I will take the "i don't know what to do" as flawed logic in your script and explanation. Thus we can only guess at what you may need?

My best guess is that you actually meant to use Else before Exit

I am going to go with that statement but use Else after Exit. It seems more logical to me considering that the Appdata <program> settings folder should be removed at the start of installation if it is a requirement.


; get the install path from registry
$PreviousInstallation = RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Registry Mechanic_is1", "InstallLocation")
If StringRight($PreviousInstallation, 1) = '\' Then
$PreviousInstallation = StringTrimRight($PreviousInstallation, 1)
EndIf

; check if installed
If $PreviousInstallation <> "" And FileExists($PreviousInstallation & "\RegMech.exe") Then
; show message and then Exit script as already installed
MsgBox(0x40010, "Registry Mechanic 9", "Please uninstall previous version of Registry Mechanic before install the progarm..")
Exit 1
Else
; remove old settings (and start installation below)
DirRemove(@AppdataDir & "\Registry Mechanic 9", 1)
EndIf

; start installation

@sahra

Attempt to comment your code and it may help you to interpret the logic of your script. It may help others also.

Link to comment
Share on other sites

That thought process makes a little more sense to me, however the hard-coding of the Appdata directory name now makes less sense. If there's already a 'Reg Mech 9' directory there but no uninstall registry data, then they've already removed 'the most recent version' of the application. Why then would they want to install a repack of it? If they did why wouldn't they wish to maintain its previous data?

Link to comment
Share on other sites

its steal doesn't work for me i don't know why its not remove the Dir.

i just want that if the MsgBox pop up so it will remove the installation Dir but if MsgBox not pop up so it remove the installation Dir after installation complete

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...