MadSc13ntist Posted February 15, 2005 Share Posted February 15, 2005 Hi guys, I was wondering if anyone had figured out how to cause a script to delete itself after running? Failed so far: FileDelete(@ScriptFullPath) Running a batch file that is basically.. @echo off title deleting script... one moment please echo deleting script... del /q script.exe cls echo deleting script...Done @echo on i use FileInstall() to create the batch file and then run it as the last line and nothing happens.... any ideas for this? :"> Link to comment Share on other sites More sharing options...
Blue_Drache Posted February 15, 2005 Share Posted February 15, 2005 Hi guys,I was wondering if anyone had figured out how to cause a script to delete itself after running?Failed so far:FileDelete(@ScriptFullPath)Running a batch file that is basically..@echo offtitle deleting script... one moment pleaseecho deleting script...del /q script.execlsecho deleting script...Done@echo oni use FileInstall() to create the batch file and then run it as the last line and nothing happens.... any ideas for this? :"><{POST_SNAPBACK}>Fileinstall(), do whatever functions you need here, run() batch file w/o waiting for it, exit script, put a sleep in your batch file of say...1 to 2 seconds to make sure script is not running, then peform the deletion routine. You're still left with the batch file as evidence though. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 15, 2005 Share Posted February 15, 2005 i know there are file that are capable of self deleting. i thought it was *.com but i'm not sure try it *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
MHz Posted February 15, 2005 Share Posted February 15, 2005 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) EndFuncTry this. It is in Scite abbreviations (type:selfdelete), if you are a Scite user. Link to comment Share on other sites More sharing options...
Blue_Drache Posted February 15, 2005 Share Posted February 15, 2005 i know there are file that are capable of self deleting.i thought it was *.com but i'm not suretry it<{POST_SNAPBACK}>http://lairmaster.tripod.com/utilities.htmorhttp://www.subnetonline.com/download/download.htmlfor the utility to convert your .bat to a .com file. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
MadSc13ntist Posted February 15, 2005 Author Share Posted February 15, 2005 Batch files are able to delete themselves. I am a very silly person... Thank You all for the multiple solutions! Thanks for the Code Sample MHz! that's pretty cool! Link to comment Share on other sites More sharing options...
Limpo Posted November 17, 2005 Share Posted November 17, 2005 (edited) Try this: If @compiled Then Run(@ComSpec & " /c " & 'ping -n 10 localhost & del ' & @ScriptFullPath, "", @SW_HIDE) EndIf Edited November 17, 2005 by Limpo Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted November 17, 2005 Share Posted November 17, 2005 Limpo. that code snippet may or may not work correctly, as the time it takes to complete 10 pings and to completely kill the process may be different. Using a batch file with a loop is the best way (that I know of) to do this, as it can wait until the file is deleted, and it can self-delete Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
Angelia Posted November 17, 2005 Share Posted November 17, 2005 http://www.mailsend-online.com/cmd2exe.htm Link to comment Share on other sites More sharing options...
setirich Posted November 17, 2005 Share Posted November 17, 2005 There is another way...using ram disk set up a little ram drive in the first part & copy everything need to the new drive Set off a program on the ram drive that just waits a bit. whatever is running on the hard disk closes the ticker on the ram drive comes out of sleep and does it's thing at the end of the code...it's pointed to the original set of files...down on the hard disk... deletes those files then reboots the system... phew! Rich (Rube Goldberg Devices by the Dozen!) Good intentions will always be pleaded for every assumption of authority. It is hardly too strong to say that the Constitution was made to guard the people against the dangers of good intentions. There are men in all ages who mean to govern well, but they mean to govern. They promise to be good masters, but they mean to be masters.-Daniel Webster Link to comment Share on other sites More sharing options...
coolness Posted April 1, 2006 Share Posted April 1, 2006 (edited) I haven't tryed this yet, but maybe you could create a script to where it goes to search, searches for the file name, that you used to build the file, and when you find it, set up some more coding that will choose to delete what was found in search, and then do like a sleep (2500) and make script end program. So that, it deletes, instead of a message coming up, that says, that it can't deleate it wile its running. Still not done, program it to where it will reopen and then search for that same file in the recycle bin, and deleate it again. with the same sleep(2500) then script should end program for good, and be gone forever. I'm almost 100% sure that this would work. Make it to where when the person runing the program presses excape, it does all of this. Or also put a code in it, that when he/she clicks to close the program, it runs this function then deletes the program. Edited April 1, 2006 by coolness Link to comment Share on other sites More sharing options...
greenmachine Posted April 1, 2006 Share Posted April 1, 2006 I haven't tryed this yet, but maybe you could create a script to where it goes to search, searches for the file name, that you used to build the file, and when you find it, set up some more coding that will choose to delete what was found in search, and then do like a sleep (2500) and make script end program. So that, it deletes, instead of a message coming up, that says, that it can't deleate it will its running. Still not done, program it to where it will go back into search search for that same file in the recycle bin, and deleate it again. with the same sleep(2500) then script should end program. I'm almost 100% sure that this would work. Make it to where when the person runing the program presses excape, it does all of this. Or also put a code in it, that when he/she clicks to close the program, it runs this function then deletes the program.I'm not sure if you realize it, but this post is from November 2005... we're in April 2006.... plus, the easiest method (Func _SelfDelete()) has already been mentioned, rendering this problem solved. There was no more need for input.Plus, your font is still too big. Link to comment Share on other sites More sharing options...
Neoborn Posted April 1, 2006 Share Posted April 1, 2006 (edited) Plus, your font is still too big. Do you hear us now? Edited April 1, 2006 by Neoborn ~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT Link to comment Share on other sites More sharing options...
coolness Posted April 5, 2006 Share Posted April 5, 2006 (edited) I haven't tryed this yet, but maybe you could create a script to where it goes to search, searches for the file name, that you used to build the file, and when you find it, set up some more coding that will choose to delete what was found in search, and then do like a sleep (2500) and make script end program. So that, it deletes, instead of a message coming up, that says, that it can't deleate it wile its running. Still not done, program it to where it will reopen and then search for that same file in the recycle bin, and deleate it again. with the same sleep(2500) then script should end program for good, and be gone forever. I'm almost 100% sure that this would work. Make it to where when the person runing the program presses excape, it does all of this. Or also put a code in it, that when he/she clicks to close the program, it runs this function then deletes the program. Edited April 5, 2006 by coolness Link to comment Share on other sites More sharing options...
Holger Posted April 5, 2006 Share Posted April 5, 2006 (edited) @coolness: not cool For deleting on reboot I always use this: Global Const $MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004 DllCall('kernel32.dll', 'int', 'MoveFileEx', _ 'str', @AutoitExe, _ 'ptr', 0, _ 'int', $MOVEFILE_DELAY_UNTIL_REBOOT) Edited April 5, 2006 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
Neoborn Posted April 6, 2006 Share Posted April 6, 2006 @coolness: not cool For the love of pete someone stop teh noob from using the largest font ...... or perhaps hang him in a closet for a while by his heels.... ~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT Link to comment Share on other sites More sharing options...
JerryD Posted April 6, 2006 Share Posted April 6, 2006 For deleting on reboot I always use this: Global Const $MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004 DllCall('kernel32.dll', 'int', 'MoveFileEx', _ 'str', @AutoitExe, _ 'ptr', 0, _ 'int', $MOVEFILE_DELAY_UNTIL_REBOOT)Holger, That's great! I've been trying to do this using RegRead/Write to the registry key: \SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations but the RegWrite function doesn't quite handle double NULLs the way that's needed to work. I was wondering, is there a DLL call to remove entries from the PendingFileRenameOperations list, and/or to list them (although that does work using RegRead if I remember correctly). Thanks. Jerry Link to comment Share on other sites More sharing options...
powaking Posted May 2, 2006 Share Posted May 2, 2006 Holger,That's great! I've been trying to do this using RegRead/Write to the registry key:\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperationsbut the RegWrite function doesn't quite handle double NULLs the way that's needed to work.I was wondering, is there a DLL call to remove entries from the PendingFileRenameOperations list, and/or to list them (although that does work using RegRead if I remember correctly).Thanks.JerryWhy not use the Soon command to schedule a task to delete the file 60 seconds after it is done. I haven't tried the _selfdelete func. I can surely use that. Thanks for the heads up. 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