ACalcutt Posted January 31, 2006 Share Posted January 31, 2006 i want to delete the exe of the scipt i am running when it is finished. is that possible without running a different script? Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
cdkid Posted January 31, 2006 Share Posted January 31, 2006 (edited) humm what about this Func OnAutoitExit() Run(@comspec & "/c del " & filegetshortname(@autoitexe)) endfunc ? ~cdkid Edited January 31, 2006 by cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 31, 2006 Moderators Share Posted January 31, 2006 (edited) In SciTe type in SelfDelete then hit the space bar.Edit:You'll use Opt('OnExitFunc', 'Function Name') Edited January 31, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ACalcutt Posted February 1, 2006 Author Share Posted February 1, 2006 Thanks Smoke_N...thats exactly what i needed Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature Link to comment Share on other sites More sharing options...
MHz Posted February 1, 2006 Share Posted February 1, 2006 Edit: You'll use Opt('OnExitFunc', 'Function Name')Nice idea, but the Opt() will not work with a function parameter. A small change to the function will allow it without error. From the current: 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 To adding the parameter within the function itself will allow Opt() to work on it: Func _SelfDelete() Local $sCmdFile, $iDelay = 0 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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 1, 2006 Moderators Share Posted February 1, 2006 Nice idea, but the Opt() will not work with a function parameter. A small change to the function will allow it without error. From the current: 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 To adding the parameter within the function itself will allow Opt() to work on it: Func _SelfDelete() Local $sCmdFile, $iDelay = 0 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 I have mine do it on exit like that, go to the exit function... do the last minute things I need, then go to the _SelfDelete($param)... with a parameter. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ACalcutt Posted February 1, 2006 Author Share Posted February 1, 2006 i just ran the _SelfDelete() function right before exit....that seemed to work fine....i only want it before that exit anyway...there are other exits in the program that i dont want it to delete at Andrew Calcutt Http://www.Vistumbler.net Http://www.TechIdiots.net Its not an error, its a undocumented feature 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