Delete master folder including the application

gstylianou

Registered User.
Local time
Today, 09:43
Joined
Dec 16, 2013
Messages
359
Good morning,

In master application folder (MyApplication) I have all the files for installing my application. Is there a way so that through a command from the database I have in this folder I can delete all the files, including the application I gave the command?

I have tried various methods without result and it would really help me the most and some idea

Thanks in advance
 
Hi. I don't think you'll be able to delete the same application that is executing that process (deleting itself). What you could try is auto-build a batch or script file that will delete all your files and folder, and then execute it from your app. You will see this technique in some FE auto update code.
 
Hi. I don't think you'll be able to delete the same application that is executing that process (deleting itself). What you could try is auto-build a batch or script file that will delete all your files and folder, and then execute it from your app. You will see this technique in some FE auto update code.
Hi, theDBguy and thank you very much. I understand what you mean but I'm not able due to the fact of my VBA skills to do something like that. Is it possible to give me one sample please?

Thanks in advance
 
Hi, theDBguy and thank you very much. I understand what you mean but I'm not able due to the fact of my VBA skills to do something like that. Is it possible to give me one sample please?

Thanks in advance
If no one else posts an example by then, I'll post something tomorrow. Cheers!
 
Open the attached database and click the button to delete itself.

It's a very simple example. You can play with timer or focus to gain what you need.
It simply gives you the idea.

Edit: I didn't delete other files because it may cause a disaster if you save the database in the wrong folder. You can use FSO Delete to files in vba to delete the files you need. then run the batch file to delete the database.
 

Attachments

Last edited:
Open the attached database and click the button to delete itself.

It's a very simple example. You can play with timer or focus to gain what you need.
It simply gives you the idea.

Edit: I didn't delete other files because it may cause a disaster if you save the database in the wrong folder. You can use FSO Delete to files in vba to delete the files you need. then run the batch file to delete the database.
Hi, reallly thank you Sun_Force, this example is 90% what i'm looking to do. The only thing is if its possible to delete all master folders, subfolders and all file within the database working path, but anyway i wil try to modify your example.

Thanks again
 
If you are running a database, then you can easily, from within the database iterate currentproject.path and delete/kill all files other than the database itself, and the ldb/laccdb file associated with the database. They may be recycled into the recycle bin, of course.

You could delete any folder structure, although it won't delete a file that's currently open.
Maybe you need to be careful, as you wouldn't want to delete a client's files that happen to be in one of the folders.

You could include an encrypted file manifest that identifies the files you actually want to delete.

If the real problem is to prevent unauthorised use, then it's really a different problem, I think, and deleting the application is not the best solution.

eg Sky just prevent you watching your stored library if you don't have a valid subscription. They don't actually try to delete your library.
 
Hi, reallly thank you Sun_Force, this example is 90% what i'm looking to do. The only thing is if its possible to delete all master folders, subfolders and all file within the database working path, but anyway i wil try to modify your example.

Thanks again
What @gemma-the-husky advised is very important. You may want to think again over your plan.

If you're still decided on your plan change the code as following:

SQL:
Dim FileNameToDelete As String
    Dim CheckExists As String
    Dim Deleter As String
    Dim fldr As String
  
    fldr = CurrentProject.Path
    Deleter = Environ("Temp") & "\Deleter.cmd"
    FileNameToDelete = CurrentProject.FullName
    CheckExists = Left(FileNameToDelete, InStrRev(FileNameToDelete, ".")) & "laccdb"
  
    Open Deleter For Output As #1
    Print #1, "Echo Off"
  
    Print #1, ": Loop"
    Print #1, "ECHO :)"
    Print #1, "if exist """ & CheckExists & """ GOTO LOOP"
    Print #1, "@DEL /s /q """ & fldr & """"
    Print #1, "Quit"
    Close #1
  
    Shell Deleter, vbNormalFocus
    DoCmd.Quit


@gemma-the-husky the files don't go to trash. They are deleted permanently.
 

Attachments

Last edited:
What @gemma-the-husky advised is very important. You may want to think again over your plan.

If you're still decided on your plan change the code as following:

SQL:
Dim FileNameToDelete As String
    Dim CheckExists As String
    Dim Deleter As String
    Dim fldr As String
 
    fldr = CurrentProject.Path
    Deleter = Environ("Temp") & "\Deleter.cmd"
    FileNameToDelete = CurrentProject.FullName
    CheckExists = Left(FileNameToDelete, InStrRev(FileNameToDelete, ".")) & "laccdb"
 
    Open Deleter For Output As #1
    Print #1, "Echo Off"
 
    Print #1, ": Loop"
    Print #1, "ECHO :)"
    Print #1, "if exist """ & CheckExists & """ GOTO LOOP"
    Print #1, "@DEL /s /q """ & fldr & """"
    Print #1, "Quit"
    Close #1
 
    Shell Deleter, vbNormalFocus
    DoCmd.Quit


@gemma-the-husky the files don't go to trash. They are deleted permanently.
Hello again, it's better to explain what is the idea. This database running on monthly payment basis and customer ask from me if someone didn't pay the monthly amount, he ask from us to delete the application as is it..!! Of course I'm not agreeded with this requirment but the customer still want it. So, that's why I'm looking to find the best way to do that. Take into account that the database is connected over ODB Service with customer server and each time the database opened, we have authentication routine so to check all related data such us serial no, ssd serial number, expiration date etc.

Soz this is the idea and that's why I'm looking to do something little bit strange...

Thanks again all of you
 
Why can't your customer delete it, if he wants it deleting?
 
Well, good morning. It seems this thread has progressed a lot while I was sleeping. Looks like I don't have to post a sample anymore. Cheers!
 
Hi, reallly thank you @Sun_Force, this example is 90% what i'm looking to do. The only thing is if its possible to delete all master folders, subfolders and all file within the database working path, but anyway i wil try to modify your example.
Please tell us why you need to do this. Your skills don't seem to support you creating applications that you will sell and this is simply not functionality that would ever be required in a normal application but it is very dangerous since you can do a lot of damage if you don't know what you are doing which is what you have already told us.
 
Please tell us why you need to do this. Your skills don't seem to support you creating applications that you will sell and this is simply not functionality that would ever be required in a normal application but it is very dangerous since you can do a lot of damage if you don't know what you are doing which is what you have already told us.
Already I explained in my last post why I want to do that. Of course I know that it's not normal this what I asked to do but it's request from customer. Of course I explained to him all these dangerous arguments if we can offer to him this opportunity but.....still want to work like this.. in any case I will delete only the front end and not the backend just in case where in the future ask from us about his data..
 
Sorry I expected to see that explanation in one of the first few threads. Every single one of us has said that this is a bad idea. If you do it, you better make sure that you don't delete ANY file that is not "yours" or there will be a lawsuit coming your way and you will loose. You can make the app refuse to open if if isn't paid for. That is fine. But deleting it goes too far and opens you to jeopardy. I'm assuming that the data is on your website because if the data is on the client's computer, how are you getting notification of payment?
 
Already I explained in my last post why I want to do that. Of course I know that it's not normal this what I asked to do but it's request from customer. Of course I explained to him all these dangerous arguments if we can offer to him this opportunity but.....still want to work like this.. in any case I will delete only the front end and not the backend just in case where in the future ask from us about his data..
Just be careful and be sure to make the customer sign an agreement that they want this, hopefully that protects a bit.

PS. I've always been impressed with how forgiving Microsoft is in some ways. For example, I bought an old used laptop once off Craigslist for $75. Used it for years with Windows 7. I'll confess that the whole time, it displayed "This copy of windows is not genuine" (while functioning perfectly). I always found the humor in that.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom