Jump to content

Recommended Posts

Posted

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]

Posted

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
Shouldn'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.
Posted

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]

  • Developers
Posted

Yep - It has been that way for a long time and is in SciTE4AutoIt3 :-)

http://www.autoitscript.com/forum/index.ph...st&p=129058

Yea, that has been in there for quite a while now.

It will be fixed in the next release.

Thanks

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.
  :)

  • Developers
Posted

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.
  :)

Posted (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 by Inverted
Posted

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...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...