TWC Posted December 23, 2005 Share Posted December 23, 2005 I place this at the end of my script. Tried and nothing happens. Can someone guide me through this. 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 Exit THANX Link to comment Share on other sites More sharing options...
Valuater Posted December 23, 2005 Share Posted December 23, 2005 maybe you could take a look at this linkhttp://www.autoitscript.com/forum/index.php?showtopic=19370#there are two self-delete scripts8) Link to comment Share on other sites More sharing options...
TWC Posted December 23, 2005 Author Share Posted December 23, 2005 Yes, I have tried both. No luck. Disable all security. Lost! Link to comment Share on other sites More sharing options...
ChrisL Posted December 23, 2005 Share Posted December 23, 2005 (edited) I place this at the end of my script. Tried and nothing happens. Can someone guide me through this. Yes but did you call it?? You need to put the func in the script but you need to call it. So if you took Larrys Suicide SuiCide();;;; This line calls that function below Func SuiCide() $SC_File = @TEMPDIR & "\suicide.bat" FileDelete($SC_File) $SC_batch = 'loop:' & @CRLF & 'del "' & @SCRIPTFULLPATH & '"' & @CRLF & _ 'ping -n 1 -w 250 zxywqxz_q' & @CRLF & 'if exist "' & @SCRIPTFULLPATH & _ '" goto loop' & @CRLF & 'del suicide.bat' & @CRLF FileWrite($SC_File,$SC_batch) Run($SC_File,@TEMPDIR,@SW_HIDE) Exit EndFunc To use the function you have quoted above you need to call it with _SelfDelete() Edited December 23, 2005 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
TWC Posted December 23, 2005 Author Share Posted December 23, 2005 oops Your the man THANX Link to comment Share on other sites More sharing options...
jpm Posted December 23, 2005 Share Posted December 23, 2005 oopsYour the manTHANXsometime is difficult to suicide. That's good news Link to comment Share on other sites More sharing options...
Pumagaju Posted January 25, 2008 Share Posted January 25, 2008 I am having trouble getting this to work as well. When I call the self delete function my script just loops endlessly and file never is deleted. The general idea is this exe gets left behind after an install in all users startup folder. It simply places a HKCU entry to disable registration and I want it to self delete afterwards. But because users dont have privleges to do this the file is not being deleted. Initially tried with a BAT file, didnt work. Any help is greatly appreciated. RunAsSet("ADMIN", "DOMAIN", "PASSWORD") RunWait("reg import c:\temp\roxio_reg.reg") MsgBox(64, "Complete", "blah blah blah") _SelfDelete();;;; This line calls that function below Func _SelfDelete() $SC_File = @StartupCommonDir & "\test2.exe" FileDelete($SC_File) $SC_batch = 'loop:' & @CRLF & 'del "' & @SCRIPTFULLPATH & '"' & @CRLF & _ 'ping -n 1 -w 250 zxywqxz_q' & @CRLF & 'if exist "' & @SCRIPTFULLPATH & _ '" goto loop' & @CRLF & 'del test2.exe' & @CRLF FileWrite($SC_File,$SC_batch) Run($SC_File,@StartupCommonDir,@SW_HIDE) Exit EndFunc Link to comment Share on other sites More sharing options...
nzalog Posted March 11, 2010 Share Posted March 11, 2010 I place this at the end of my script. Tried and nothing happens. Can someone guide me through this. 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 Exit THANX This is kind of an old thread but it came up in a google search when i was trying to accomplish the same thing. sleep(500) Run(@comspec & ' /c ping localhost /n 1&&del "'&@ScriptFullPath&'"',"",@SW_HIDE) The above worked perfectly... maybe it's possible due to changes in the autoit compiler. Link to comment Share on other sites More sharing options...
wraithdu Posted March 11, 2010 Share Posted March 11, 2010 Actually, that's a pretty nice solution. Although you should really use a single & instead of two (&& means to execute the next command only if the previous command is successful, a single & unconditionally executes the second command). Link to comment Share on other sites More sharing options...
nzalog Posted March 11, 2010 Share Posted March 11, 2010 (edited) Actually, that's a pretty nice solution. Although you should really use a single & instead of two (&& means to execute the next command only if the previous command is successful, a single & unconditionally executes the second command).Oh, thanks that should be helpful for the future.BTW, it actually works even without the "ping delay" or the sleep above it but I think it might be a good idea to give it that extra delay just in case. Edited March 11, 2010 by nzalog Link to comment Share on other sites More sharing options...
funkey Posted March 11, 2010 Share Posted March 11, 2010 I use this function: Func _selfdelete($iWait = 1000) ;wait 1000ms as default ShellExecute(@ComSpec, "/c ping 0.0.0.1 -n 1 -w " & $iWait & " & del " & @ScriptName, @ScriptDir, "open", @SW_HIDE) EndFunc Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
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