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

x
?
Solved

self-destruction vb program

Posted on 1999-07-10
4
Medium Priority
?
1,195 Views
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 ?
0
Comment
Question by:howtobe
[X]
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
4 Comments
 
LVL 3

Accepted Solution

by:
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 APP.EXE..you 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



0
 

Author Comment

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

Expert Comment

by:rmichels
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
            Else
                DoEvents
                counter = counter + 1 'keep from infinite loop
            End If
        Wend
   
    End If
End Sub

0
 

Author Comment

by:howtobe
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.
0

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