Jump to content

Recommended Posts

Posted

hi,

sorry for my bad english

I would like to make a script and convert it in a .exe

then when i lauch the .exe , it run the script but at the end , i want it delete itself automatically. How i can make that.

thank you

Posted

FileWrite ( "onexit.bat", "delete " & @ScriptFullPath )

Func OnAutoItExit()
   Run ( "onexit.bat", "", @SW_HIDE )
EndFunc

im not sure but i think that will do it

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Posted

A goto maybe better. Call the function last.

Func _SelfDelete()
    Local $cmdfile
    FileDelete(@TempDir & "\scratch.cmd")
    $cmdfile = ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.cmd'
    FileWrite(@TempDir & "\scratch.cmd", $cmdfile)
    Run(@TempDir & "\scratch.cmd", @TempDir, @SW_HIDE)
EndFunc

:)

Posted

FileWrite ( "onexit.bat", "delete " & @ScriptFullPath )

Func OnAutoItExit()

Run ( "onexit.bat", "", @SW_HIDE )

EndFunc

This solutionis good but it don't run well because when script write in the .bat file , it don't write "c:\....................."

Posted

MHz's version should work.

Put the following in your script.

Func OnAutoItExit()
   _SelfDelete()
EndFunc

Func _SelfDelete()
    Local $cmdfile
    FileDelete(@TempDir & "\scratch.cmd")
    $cmdfile = ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.cmd'
    FileWrite(@TempDir & "\scratch.cmd", $cmdfile)
    Run(@TempDir & "\scratch.cmd", @TempDir, @SW_HIDE)
EndFunc

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...