Sign in to follow this  
Followers 0
T0M50N

Uninstall Script

4 posts in this topic

Hello,

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=deletered.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
If MsgBox(4, "Confirmation", "Are you sure you want to remove Blizz Video Editor and all of its components?") = 6 Then
    FileDelete(@DesktopDir&"\Blizz Video Editor.lnk")
    DirRemove(@StartMenuDir&"\Programs\Blizz Video Editor", 1)
    DirRemove(@ScriptDir, 1)
    MsgBox(0, "Success", "Program uninstalled successfully.")
Else
    MsgBox(0, "Thanks", "I knew you would make the right decision :)")
EndIf

When I run the script normally it works as expected.

When I run a compiled version of the script, DirRemove(@ScriptDir, 1) no longer works. How can I fix this?

So far I have tried:

Using @WorkingDir instead.

Adding a backslash after @ScriptDir.

Share this post


Link to post
Share on other sites



So you want to delete the directory from which the program is running as an EXE?

The running exe will lock the directory as it is in use at the moment of execution,

Look for _SelfDelete() for a way to remove the program after the program completes.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

But wouldn't that leave an empty directory?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Found a solution:

Func _SelfDeleteDir($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _
             & ':loop' & @CRLF _
             & 'RD /S /Q "' & @ScriptDir & '"' & @CRLF _
             & 'if exist "' & @ScriptDir & '" goto loop' & @CRLF _
             & 'RD /S /Q %0' & @CRLF _
             & 'del /q /f "%~f0" >nul 2>&1 & exit /b 0' & @CRLF
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc;==>_SelfDelete

This doesn't leave the scratch.bat in the temp dir either.

Edited by T0M50N

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