alucard Posted March 29, 2005 Posted March 29, 2005 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
zcoacoaz Posted March 29, 2005 Posted March 29, 2005 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]
MHz Posted March 29, 2005 Posted March 29, 2005 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
alucard Posted March 29, 2005 Author Posted March 29, 2005 FileWrite ( "onexit.bat", "delete " & @ScriptFullPath )Func OnAutoItExit() Run ( "onexit.bat", "", @SW_HIDE )EndFuncThis solutionis good but it don't run well because when script write in the .bat file , it don't write "c:\....................."
SlimShady Posted March 29, 2005 Posted March 29, 2005 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
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