T0M50N Posted April 19, 2014 Posted April 19, 2014 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.
Developers Jos Posted April 19, 2014 Developers Posted April 19, 2014 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
T0M50N Posted April 19, 2014 Author Posted April 19, 2014 But wouldn't that leave an empty directory?
Solution T0M50N Posted April 19, 2014 Author Solution Posted April 19, 2014 (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 April 19, 2014 by T0M50N
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now