t0ddie Posted February 21, 2010 Posted February 21, 2010 $batchFile = 'loop:' & @CRLF & 'del "' & @SCRIPTFULLPATH & '"' & @CRLF & _ 'ping -n 1 -w 250 zxywqxz_q' & @CRLF & 'if exist "' & @SCRIPTFULLPATH & _ '" goto loop' & @CRLF & 'del scratch.bat' & @CRLF FileWrite ("scratch.bat", $batchFile) Run ("scratch.bat", @SCRIPTDIR, @SW_HIDE) Exit this used to work. is there a substitute? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
Fire Posted February 21, 2010 Posted February 21, 2010 Just searched and i found this:About SelfDelete [size="5"] [/size]
BrettF Posted February 21, 2010 Posted February 21, 2010 Hi, 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 Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
t0ddie Posted February 21, 2010 Author Posted February 21, 2010 (edited) that function does not work for me i tried it two ways. _AutoDestroy() Func _AutoDestroy() Do $destroFileTemp= "destroy.bat" $destroFileTemp = @MIN & @SEC & $destroFileTemp Until FileExists($destroFileTemp) = 0 if @Compiled = 1 Then $file = FileOpen($destroFileTemp, 1) FileWriteLine($file, "pause") FileWriteLine($file, "del " & @ScriptFullPath) FileWriteLine($file, "del " & $destroFileTemp) FileClose($file) Run(@ScriptDir & "\" & $destroFileTemp);$s_Command & $s_Mask & '"', @WorkingDir, @SW_HIDE, 2+4)@ComSpec & "/c " & Exit EndIf EndFunc Func _OnAutoitExit() Do $destroFileTemp= "destroy.bat" $destroFileTemp = @MIN & @SEC & $destroFileTemp Until FileExists($destroFileTemp) = 0 if @Compiled = 1 Then $file = FileOpen($destroFileTemp, 1) FileWriteLine($file, "pause") FileWriteLine($file, "del " & @ScriptFullPath) FileWriteLine($file, "del " & $destroFileTemp) FileClose($file) Run(@ScriptDir & "\" & $destroFileTemp);$s_Command & $s_Mask & '"', @WorkingDir, @SW_HIDE, 2+4)@ComSpec & "/c " & Exit EndIf EndFunc the first one opened a cmd prompt but it did not delete file the second one did nothing at all. but this one works _SelfDelete() 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 Edited February 21, 2010 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
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