DEKK3R Posted November 4, 2008 Share Posted November 4, 2008 (edited) Any one know if it's possible to write a script that, when compiled, is able to delete itself and the directory in which it resides? Before the script is compiled, it's no problem....but i guess that's because the Autoit interpreter is doing the work - not the .exe. Any ideas anyone? Edited November 5, 2008 by DEKK3R Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 4, 2008 Share Posted November 4, 2008 Self-deletion has been discussed before, repeatedly. Next time use the search feature. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Developers Jos Posted November 4, 2008 Developers Share Posted November 4, 2008 Sure... many times asked and answered: look for _SelfDelete() function in the helpfile. Just take this UDF and expand it so it also deletes the directory... 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. Link to comment Share on other sites More sharing options...
DEKK3R Posted November 4, 2008 Author Share Posted November 4, 2008 Thanks a lot - and yes, point taken, i should have used search....just didn't think it would have been covered for some reason. I'll look into _SelfDelete() as suggested. However, i was hoping for a solution that achieved the same without batch files or a temp dir, etc. Thanks again Link to comment Share on other sites More sharing options...
Developers Jos Posted November 4, 2008 Developers Share Posted November 4, 2008 (edited) Thanks a lot - and yes, point taken, i should have used search....just didn't think it would have been covered for some reason.I'll look into _SelfDelete() as suggested. However, i was hoping for a solution that achieved the same without batch files or a temp dir, etc.Thanks againYou have a catch 22 situation... the process needs to delete its executable+directory but the process needs to end first before thats possible.That is why a second process is needed. Edited November 4, 2008 by 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. Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 4, 2008 Share Posted November 4, 2008 Theoretically you could load the executable into memory and end the process and use the one in memory to delete the file,but batch is definitely the easiest. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
DEKK3R Posted November 4, 2008 Author Share Posted November 4, 2008 You have a catch 22 situation... the process needs to delete its executable+directory but the process needs to end first before thats possible.That is why a second process is needed.Yep.....that's exactly the problem. However, theoretically if there was a way of ensuring the compiled script ran exclusively from memory then surely this problem could be overcome. Link to comment Share on other sites More sharing options...
DEKK3R Posted November 4, 2008 Author Share Posted November 4, 2008 Theoretically you could load the executable into memory and end the process and use the one in memory to delete the file,but batch is definitely the easiest.Yes, dbzfanatic - just read your reply after i posted my last comment. Any idea how to make this happen? Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 4, 2008 Share Posted November 4, 2008 1) there is an edit button, please use it. 2) I'm not 100% sure how to achieve this and I would need to know the exact circumstances to tell someone if I did. A batch file would honestly be the simplest method and not really a problem unless you were intending to write some kind of malware and wanted to leave no trace of the installer/injector. We've had many people ask for help with malware so most of us are a bit suspicious, nothing personal but we want to keep autoit a clean language (or at least as clean as possible). Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
DEKK3R Posted November 4, 2008 Author Share Posted November 4, 2008 Yes, i see your point re malware but it's nothing more sinister than this - i'm an old programmer who's just started to write code again after about 20 yrs! Back then every byte counted and it would be unforgivable to leave something behind. The .bat file answer looks like the solution I'll have to go with...thanks for your help. Link to comment Share on other sites More sharing options...
TehWhale Posted November 4, 2008 Share Posted November 4, 2008 Hello, It appears you have found your answer to your question. Please take the time to edit your thread title with [RESOLVED] so others know that is it resolved. You can do this by scrolling to the top of your thread, clicking EDIT and then Full Edit and adding: "[RESOLVED]" to the front of your thread title. Thanks for your cooperation. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 4, 2008 Developers Share Posted November 4, 2008 (edited) Hello, It appears you have found your answer to your question. Please take the time to edit your thread title with [RESOLVED] so others know that is it resolved. You can do this by scrolling to the top of your thread, clicking EDIT and then Full Edit and adding: "[RESOLVED]" to the front of your thread title. Thanks for your cooperation.Wondering if this was ever agreed upon somewhere and if this is now going to be told to all the others that post the dozens of questions and aren't doing it at this moment. Edited November 4, 2008 by 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. Link to comment Share on other sites More sharing options...
TehWhale Posted November 4, 2008 Share Posted November 4, 2008 Wondering if this was ever agreed upon somewhere and if this is now going to be told to all the others that post the dozens of questions and aren't doing it at this moment.I tried it a while back to see if it worked, but it didnt. I'll stop now. Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 4, 2008 Share Posted November 4, 2008 I've been trying it too and it works about 50% of the time, besides it does help for searching and it's kind of fun to tell people . Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 4, 2008 Share Posted November 4, 2008 You can't load an executable into memory and have it delete the physical file because when the physical file's process ends, the memory resident executable will no longer have space to execute in. Unless you feel like injecting it into some other application's space. That could cause a lot of instability though. Just use the batch file method. Link to comment Share on other sites More sharing options...
madasraka Posted March 25, 2010 Share Posted March 25, 2010 This code will expandcollapse popup#include <ProgressConstants.au3> $FileToUpdate = "my program.exe" $FileToDownload = "compressed.rar" $FileDownloadURL = "http://www.mywebsite.com" $FileToReplace = (@ScriptDir & "\" & $FileToUpdate) $Decompressor = "UnRAR.exe" $DecompressCommand = ($Decompressor & " x -o+ " & $FileToDownload) Updater() Func Updater() FileRecycle (@ScriptDir & "\" & $FileToDownload) ProcessWaitClose ($FileToUpdate) ;Wait for process to close before file will be available for replacement $FileSize = InetGetSize ($FileDownloadURL & $FileToDownload,1) $FileDownloading = InetGet ($FileDownloadURL & $FileToDownload, @ScriptDir & "\" & $FileToDownload,1,1) ;1 for Force redownload, 1 for Do not wait till downloaded and go next ProgressOn ("Download progress", "Downloading file ", "0 %") ;start progress bar windows For $i = 1 to $FileSize step 1 $FileDownloadingInfo = InetGetInfo ($FileDownloading) $FilePercentDownloaded = Round($FileDownloadingInfo[0]*100/$FileSize, 2) ProgressSet($FilePercentDownloaded, $FilePercentDownloaded & " %") ;GUICtrlSetData ($progress,$percentDownloaded) If InetGetInfo($FileDownloading,2) Then InetClose($FileDownloading) ExitLoop Else ContinueLoop EndIf Next ProgressOff() ProgressSet(100 , "100%", "Download completed.") RunWait ($DecompressCommand) FileMove (@ScriptDir & "\" & $FileToUpdate,@ScriptDir & "\" & $FileToUpdate,1) MsgBox(0,'','') FileRecycle (@ScriptDir & "\" & $FileToDownload) ;erase downloaded file MsgBox(0,'Information','Update Complete !') EndFunc Link to comment Share on other sites More sharing options...
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