rudika Posted October 7, 2006 Share Posted October 7, 2006 Moin, moin...! Is there a possibility that a compiled EXE-file deletes itself after its execution? I would like to write an uninstallation routine for a program, which does not leave any remainders on the harddisk, therefore the Uninstall.exe must delete itself and the including directory. Is that possible? Thank you for help. Greets Rudika [font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font] Link to comment Share on other sites More sharing options...
Developers Jos Posted October 7, 2006 Developers Share Posted October 7, 2006 Moin, moin...! Is there a possibility that a compiled EXE-file deletes itself after its execution? I would like to write an uninstallation routine for a program, which does not leave any remainders on the harddisk, therefore the Uninstall.exe must delete itself and the including directory. Is that possible? Thank you for help. Greets Rudika posted a long time ago by ?? and is part of the abbrevs in SciTE: Func _SelfDelete($iDelay = 0) Local $sCmdFile FileDelete(@TempDir & "\scratch.bat") $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ & ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFunc 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...
cppman Posted October 7, 2006 Share Posted October 7, 2006 (edited) posted a long time ago by ?? and is part of the abbrevs in SciTE: Func _SelfDelete($iDelay = 0) Local $sCmdFile FileDelete(@TempDir & "\scratch.bat") $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ & ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFunc ~Works fine for me I guess this answers your question rudika. lol. Edited October 7, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Developers Jos Posted October 7, 2006 Developers Share Posted October 7, 2006 All That? Why not just do this? Func DeleteSelf() RUn(@ComSpec & " /k del " & FileGetShortName(@ScriptFullPath), @ScriptDir, @SW_HIDE) EndFunc ~Works fine for me I guess this answers your question rudika. lol.Did you try a compiled version ? Don't think you can DEL a running program.. 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...
cppman Posted October 7, 2006 Share Posted October 7, 2006 (edited) Yeah, i did it with both compiled and uncompiled. It works just fine. Have you tried it? Edited October 7, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 7, 2006 Share Posted October 7, 2006 Hi, your version doesn't work. That is why there is the selfdelete func. Try this: <-- will not work. HotKeySet("1", "end") while 1 Sleep(1000) WEnd Func end() MsgBox(0,"","SelfDelete") Run(@ComSpec & " /k del " & FileGetShortName(@ScriptFullPath), @ScriptDir, @SW_HIDE) EndFunc ;==>end So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
cppman Posted October 7, 2006 Share Posted October 7, 2006 (edited) hmm.. I dont understand.. It works just fine for me lol. I sat here and watched it dissappear off my desktop ---oh well. Edited October 7, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
Developers Jos Posted October 7, 2006 Developers Share Posted October 7, 2006 (edited) Yeah, i did it with both compiled and uncompiled. It works just fine. Have you tried it?This seems to work pretty good.... But any time the programs takes too long to close down , it will not be deleted... sleep(50) Func OnExitFunc() RUn(@ComSpec & " /k del " & FileGetShortName(@ScriptFullPath), @ScriptDir, @SW_HIDE) EndFunc Edited October 7, 2006 by JdeB 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...
Administrators Jon Posted October 7, 2006 Administrators Share Posted October 7, 2006 Depends on the speed of your machine. Run() starts...and there is a chance that script will exit before the Run() command actually gets to work. If so it will work. For most people it won't. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
cppman Posted October 7, 2006 Share Posted October 7, 2006 ah.. kk, i was just now thinking that. Thx. Miva OS Project Link to comment Share on other sites More sharing options...
rudika Posted October 7, 2006 Author Share Posted October 7, 2006 (edited) Depends on the speed of your machine. Run() starts...and there is a chance that script will exit before the Run() command actually gets to work. If so it will work. For most people it won't. I´ll thank you everybody. Correctly, Jon... I have both tested variants, however only the suggestion of JdeB is practicable, but I have still modified somewhat, so that it delete the whole directory. But I don´t really understand the ping... Func _SelfDelete($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 _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFunc So it works like I wanted. Greets Rudika Edited October 7, 2006 by rudika [font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font] Link to comment Share on other sites More sharing options...
cppman Posted October 7, 2006 Share Posted October 7, 2006 I´ll thank you everybody. Correctly, Jon... I have both tested variants, however only the suggestion of JdeB is practicable, but I have still modified somewhat, so that it delete the whole directory. But I don´t really understand the ping... Func _SelfDelete($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 _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFunc So it works like I wanted. Greets RudikaThe ping is to keep the program running. That way your program closes before the command "del" is ever executed. Miva OS Project Link to comment Share on other sites More sharing options...
Zedna Posted October 8, 2006 Share Posted October 8, 2006 But I don´t really understand the ping...It's workaround for missing Sleep() in DOS batch files Batch file file start deleting/testing successfull delete/loop after some timeout Resources UDF ResourcesEx UDF AutoIt Forum Search 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