Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


self-destruction vb program

Posted on 1999-07-10
Medium Priority
Last Modified: 2010-05-18
I am tring to do self-destruction program in vb, but I got
path/file access error number 75. Here is my code :

Kill App.Path & "\" & App.EXEName & ".exe"

what's wrong ? How to correct it ?
Question by:howtobe
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

rmichels earned 60 total points
ID: 1523462
You can't delete the EXE because you are currently running it.  Windows will have it marked as in use.

what you could do is create 2 exe files (two VB programs).

say the one you want to destroy is called APP.EXE.  The other is called DELAPP.EXE.  When you want to destroy your application, have it SHELL DELAPP.EXE and immediately End.  Then in DELAPP, delete APP.EXE.  You'll still have DELAPP laying around though.  You may have some timing issues, with DELAPP  trying to delete may have to keep retrying the KILL command, until it succeeds.

Make sure you check if APP.EXE is there, before you delete it, that way DELAPP won't be stuck in an infinite retry loop if someone happens to run it, after it has done it's deletion


Author Comment

ID: 1523463
I think I just understand half of it. Can you be more clear or will you show me the example ? Thanks

Expert Comment

ID: 1523464
In the primary app, the one you want to be deleted..I put in form1_Unload

  Shell "d:\deleteit.exe" (of course modify the path to your specs)

at the end of the unload sub

I created another app, called deleteit.exe.

In project settings, startup is Sub Main

Option Explicit

Sub Main()
    Dim b_deleted As Boolean
    Dim counter as integer
    If Dir("d:\project1.exe") <> "" Then 'modify path for your specs
        While Not b_deleted and counter < 100
            On Error Resume Next
            Kill "d:\project1.exe" 'modify path
            If Err.Number = 0 Then
                b_deleted = True
                counter = counter + 1 'keep from infinite loop
            End If
    End If
End Sub


Author Comment

ID: 1523465
I am sure these code will work but please give
me 2 days to verify. I am busy right now.

Thank a lot.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question