Welcome to Dream.In.Code
Become a VB Expert!

Join 149,960 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,340 people online right now. Registration is fast and FREE... Join Now!




File suicide.

 
Reply to this topicStart new topic

File suicide., How to make and exe delete itself.

benpap
31 Dec, 2007 - 05:32 PM
Post #1

New D.I.C Head
Group Icon

Joined: 24 Nov, 2007
Posts: 44


Dream Kudos: 100
My Contributions
Hello there, I was wondering how an exe file can delete itself after doing its work. I belive we use the kill command.

I tried the following.

Added a command button and then used this as a code:
CODE

End
Kill "selfkiller.exe"

The selfkiller.exe is the program itself.

I really didnt think it would work and of course it did't.
In case I put the kill command first an error appears that it can't access the file, which is logical because it is in use.

Help me out if you can, thx! smile.gif
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: File Suicide.
31 Dec, 2007 - 06:44 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well there is a few tricks you can use and all of them depend on the type of operating system you have, but one method is to create a batch file to do the deleting, another is to make calls to the windows API. There are a few others as well. You can read up on all the different methods at the link below...

Self-deleting executables

The author has done a nice job of outlining several ways of doing this task so I will leave it up to him to explain them all. Check out the link and I am sure you will see one that works for your situation.

The code is in C/C++ but you can still make calls to the windows API by importing various DLLs and such.

Enjoy! smile.gif
User is offlineProfile CardPM
+Quote Post

benpap
RE: File Suicide.
1 Jan, 2008 - 07:32 AM
Post #3

New D.I.C Head
Group Icon

Joined: 24 Nov, 2007
Posts: 44


Dream Kudos: 100
My Contributions
I'll find my answer definetly, a lot of thanks!
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: File Suicide.
1 Jan, 2008 - 10:57 AM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
If it were me I would go with the batch file as you can call a batch file from within code using the System.Diagnostics.Process Namespace, but thats just my opinion smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 06:14PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month