View Full Version : How to create application, which deletes itself?
Hofiiik
12-21-2008, 07:22 AM
Hi,
I have this problem with Autoplay Media Studio: I want to create an application, which deletes itself (which means, it deletes autorun.exe file and folder AutoPlay) after it is closed.
I've tried to put the action File.Delete to On Shutdown, but it doesn't work. Could you help me please?
ShadowUK
12-21-2008, 07:54 AM
Hi,
I have this problem with Autoplay Media Studio: I want to create an application, which deletes itself (which means, it deletes autorun.exe file and folder AutoPlay) after it is closed.
I've tried to put the action File.Delete to On Shutdown, but it doesn't work. Could you help me please?
Make a bat script that does something like
@echo off
sleep 5
del autorun.exe (sleep: http://www.computerhope.com/download/utility/sleep.exe)
and in AMS
File.run, application.exit
Imagine Programming
12-21-2008, 09:29 AM
you could also delete the batch file itsels but that's not always working really good
@echo off
sleep 5
del autorun.exe
del the_bat_filename.bat
Hofiiik
12-21-2008, 12:41 PM
Unfortunatelly, it doesn't work.
I wrote a BAT file, but it seems, that the command "sleep" doesn't work, because the BAT file runs immediatelly after I close my autorun.exe file (even if I wrote there "sleep 5000")...
Imagine Programming
12-21-2008, 12:43 PM
Unfortunatelly, it doesn't work.
I wrote a BAT file, but it seems, that the command "sleep" doesn't work, because the BAT file runs immediatelly after I close my autorun.exe file (even if I wrote there "sleep 5000")...
You've gotta download sleep.exe (link in Shadow's post) and put it either in the folder that containes the batch file, or in System32.
Hofiiik
12-21-2008, 12:52 PM
Problem solved!
I did it exactly how you wrote, but I forgot, that I set a working folder for BAT file and I didn't copy "sleep.exe" into this folder - now it works fine. Thank you very much :yes
PS: Is there a way how to set a delay lower than 1 second? (I tried to type there 0.2, but it didn't work...).
Imagine Programming
12-21-2008, 01:08 PM
Problem solved!
I did it exactly how you wrote, but I forgot, that I set a working folder for BAT file and I didn't copy "sleep.exe" into this folder - now it works fine. Thank you very much :yes
PS: Is there a way how to set a delay lower than 1 second? (I tried to type there 0.2, but it didn't work...).
I would stick to 5 seconds, you don't know how long it takes until the application is fully stopped on slower systems... I don't think there's a way to go under 1 second.
ShadowUK
12-21-2008, 01:13 PM
Just incase you could do TASKKILL /F /IM autorun.exe or something similiar.
http://box-project.org.uk/uploads/cmd.png
Imagine Programming
12-21-2008, 02:25 PM
But if there's more then 1 autorun.exe (eg: two Web-Executables) it ends all of them, doesn't it?
I use this:
tbl_selfdelete = {"@echo off","for /L %%q in (1,1,20) do (","ping -n 1 -w 2000 1.1.1.1 > nul","del /F /Q \"".._SourceFolder.."\\autorun.exe\" > nul","rd \"".._SourceFolder.."\\autorun\"" /Q > nul","if not exist \"".._SourceFolder.."\\autorun.exe\" goto exit",")",":exit","del \"".._TempFolder.."\\_del.bat > nul"}
TextFile.WriteFromTable(_TempFolder.."\\_del.bat", tbl_selfdelete, false)
Shell.Execute(_TempFolder.."\\_del.bat", "", "", _TempFolder, SW_MINIMIZE, false)
Application.Exit()
Edited to delete the Autoplay-Folder:
tbl_selfdelete = {"@echo off","for /L %%q in (1,1,20) do (","ping -n 1 -w 2000 1.1.1.1 > nul","del /F /Q \"".._SourceFolder.."\\autorun.exe\" > nul","rd \"".._SourceFolder.."\\AutoPlay\" /Q /S > nul","if not exist \"".._SourceFolder.."\\autorun.exe\" goto exit",")",":exit","del \"".._TempFolder.."\\_del.bat > nul"}
TextFile.WriteFromTable(_TempFolder.."\\_del.bat", tbl_selfdelete, false)
Shell.Execute(_TempFolder.."\\_del.bat", "", "", _TempFolder, SW_MINIMIZE, false)
Instead of a sleep, just use ping, like crj suggested.
fikri
12-23-2008, 08:16 PM
And what if application is on CD???:wow
Imagine Programming
12-24-2008, 02:20 AM
well then you simply can't erase it :P well...you actually can by removing the disc from your computer, and throw it down from 8 stories high?
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.