Jump to content
Sign in to follow this  
AntiVirusGuy

delete script when done

Recommended Posts

Does anyone no how to delet a script when it is done as not to leave anything behind? For central deployment

In SciTe type in SelfDelete + SpaceBar Edited 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.

Share this post


Link to post
Share on other sites

Very beginning or very end are the usual places you can put it.

Just remember make a call to _SelfDelete() before your script exits.

You could also use the OnAutoItExit feature (might require beta):

Func OnAutoItExit()
;following code causes script to delete itself
    Local $sCmdFile
    FileDelete(@TempDir & "\Scratch.bat")
    $sCmdFile = ':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

Share this post


Link to post
Share on other sites

Func OnAutoItExit()
;following code causes script to delete itself
    Local $sCmdFile
    FileDelete(@TempDir & "\Scratch.bat")
    $sCmdFile = ':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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×
×
  • Create New...