liten Posted July 2, 2009 Share Posted July 2, 2009 I want a file to delete its self after its done running would i just do this with DirRemove? My UDF:Freeze.au3-Freeze values like CE, ML, ETC[i][/i][u][/u] Link to comment Share on other sites More sharing options...
herewasplato Posted July 3, 2009 Share Posted July 3, 2009 I want a file to delete its self ...Is this "file" an AutoIt script? If yes, this you might want to consider this UDF from the FAQ: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;==>_SelfDelete [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
martin Posted July 3, 2009 Share Posted July 3, 2009 Is this "file" an AutoIt script? If yes, this you might want to consider this UDF from the FAQ: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;==>_SelfDeleteShouldn't $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ be $sCmdFile = 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _ ? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
liten Posted July 3, 2009 Author Share Posted July 3, 2009 and i dont understand how i am supposr to plug that in , i menan wat do i replace, @dir?? My UDF:Freeze.au3-Freeze values like CE, ML, ETC[i][/i][u][/u] Link to comment Share on other sites More sharing options...
herewasplato Posted July 3, 2009 Share Posted July 3, 2009 Shouldn't $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ be $sCmdFile = 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _ ?Yep - It has been that way for a long time and is in SciTE4AutoIt3 :-) http://www.autoitscript.com/forum/index.ph...st&p=129058 [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted July 3, 2009 Share Posted July 3, 2009 and i dont understand how i am supposr to plug that in , i menan wat do i replace, @dir??maybe ;your code here Func OnAutoItExit() _SelfDelete(5) ; delay in seconds EndFunc ;==>OnAutoItExit Func _SelfDelete($iDelay = 0) Local $sCmdFile FileDelete(@TempDir & "\scratch.bat") $sCmdFile = 'ping -n ' & $iDelay & ' 127.0.0.1 > nul' & @CRLF _ & ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '" > nul' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFunc ;==>_SelfDelete [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Developers Jos Posted July 3, 2009 Developers Share Posted July 3, 2009 Yep - It has been that way for a long time and is in SciTE4AutoIt3 :-)http://www.autoitscript.com/forum/index.ph...st&p=129058Yea, that has been in there for quite a while now.It will be fixed in the next release.ThanksJos 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...
Inverted Posted July 3, 2009 Share Posted July 3, 2009 (edited) Why not use the -w parameter to make it timeout for the milliseconds we need ?http://www.robvanderwoude.com/wait.php Edited July 3, 2009 by Inverted Link to comment Share on other sites More sharing options...
Developers Jos Posted July 3, 2009 Developers Share Posted July 3, 2009 Why not use the -w parameter to make it timeout for the milliseconds we need ?http://www.robvanderwoude.com/wait.php-w only does something for timeout. 127.0.0.1 gives a response so there is no timeout condition? 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...
Inverted Posted July 3, 2009 Share Posted July 3, 2009 (edited) Right, well, then it needs a non-existent IP like in that link I edited later. PING 1.1.1.1 -n 1 -w 60000 >NUL Now that I think about it, it's not really important for the purposes of this thread. Edited July 3, 2009 by Inverted Link to comment Share on other sites More sharing options...
KaFu Posted July 3, 2009 Share Posted July 3, 2009 and i dont understand how i am supposr to plug that in , i menan wat do i replace, @dir??You're not clear enough about what you want to accomplish. In the title you say delete dir, in the post that the exe should delete itself. So... should the exe delete itself after running, and which dir do you want to remove? For dir removal there is the function DirRemove ( "path" [, recurse] ), set recurse = 1 to delete all subdirectories too... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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