Sign in to follow this  
Followers 0
AntiVirusGuy

delete script when done

6 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
Share on other sites

hey thanks !!! I take it this needs to be at the end of my script

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

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

does not work I must be spacing it what am I doing wrong?

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  
Followers 0