How to Delete Files When Program Closes Automatically [BAT File]

I have to remove files each time I launch an application (to resets my trial period). Is there a way to have them automatically erased when the software closes?

Best Answered by

Dany· Answered on Feb 22, 2023

In your situation, you are just tired of deleting files every single time before you launch the program. The best way to delete files automatically is to make a BAT file (Batch file). Maybe you don't know how to make a Batch file, and we will show you how to do that. Once you know how, generating a batch file to automate repeated activities is simple.

1. Start a text document, such as one in WordPad or Notepad.

2. Type your instructions in the following order:

  • del c:\folder\file
  • c:\folder\program.exe

3. Save your document with the BAT file extension, such as xxx.bat.

4. Double-click the BAT file you just produced to launch your batch file.

5. Select Edit by right-clicking the BAT file and entering your batch file's name.

After running this Batch file, the files you want to delete will be deleted automatically, and then the program will be launched.

With batch scripts, difficult operations may be made simple if they need to be repeated repeatedly, such as arranging files, opening several web pages, renaming files collectively, or making duplicates of crucial papers.

If you lost some files while using a Batch file, you could recover them with a functional data recovery program – EaseUS Data Recovery Wizard. You only need to download and install this safe tool on your computer or laptop, and you can select the target disk to scan for lost files. This software can scan data on an SD card, HDD, SSD, external hard drive, USB flash drive, etc. You can preview the files after selecting them.

Use EaseUS Data Recovery Wizard to recover deleted or lost files easily and quickly.

Tutorials on how to recover lost, deleted, or formatted data from HDD, SSD, USB, SD card, or other storage media on Windows and Mac.

People Also Ask

How to Delete a File/Folder at Logon [GPO Script Settings]

It is not a good thing that agents and supervisors can check some sensitive information. We will help you use the logon/logoff script to solve the issue in this passage.


Feb 22, 2023

How to Recover Deleted Minecraft File on PS4

Did you lose game data on your PC, Steam, PS4, or other devices? Don't panic. You can find the best ways to recover lost game data from any device. EaseUS game data recovery software best retrieves lost game data from PS4. Read on to get more information.


Feb 22, 2023

How to Delete All Files That Do Not Match Criteria

Do you want to learn how to remove a file using a script? Don't worry because this post will show you how to delete numerous files with the Remove-item cmdlet and how to delete files that do not match the criteria.


Mar 10, 2023

How to Recover Crashed Excel Files or Restore Its Previous Version

This post includes complete solutions to help you perform Microsoft Excel file recovery. If you accidentally deleted Excel files, lost an unsaved Excel file, or Microsoft Excel 2016 crashed on saving or opening files, relax. Follow the fixes here to restore your lost Excel files with ease now.


Mar 10, 2023

Can't Delete PDF Files from A Shared Folder, What Can I Do

Shift + Delete can be used to delete PDF files or directories permanently. If you still can't remove PDF files on a Windows server, read how to force delete a PDF file that won't be deleted on your Windows PC.


Mar 10, 2023

How to Delete Files from Archive by Text File

Renaming a file within a zip bundle is similar. Even in these circumstances, you can extract everything before zipping it back into a new file or overwriting the old one. So, keep reading this post to acquire the 2023 guide.


Feb 22, 2023