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 Jul 20, 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

Is It Impossible to Completely Delete Files from the Computer

When you delete a file from your computer, it does not simply vanish - at least not immediately. The data may be recoverable. This guide will show you how to permanently delete files so they cannot be recovered in Windows 11/10/8/7.


Jul 20, 2023

The File Replication Service May Delete Files, What Can I Do

The DFS file replication may delete files; thus, you can refer to this post to learn how to avoid the circumstance by correctly using the command lines and Windows PC server. And after unintentional deletion, you can recover them with the help of the EaseUS Data Recovery Wizard.


Jul 20, 2023

How to Fix Missing File Headers Error on Windows 11/10

You can fix the header missing error by using the best manual options in this guide. Besides, you can run the EaseUS file repair tool for File Repair to fix corrupted Word, Excel, PowerPoint, and PDF files with header-related issues.


Jul 20, 2023

Accidentally Deleted a Photo, How to Recover It

How to recover an accidentally deleted photo? If you accidentally deleted your photo on Windows PC, don't worry! This article will introduce effective photo recovery software. Read on to learn detailed information.


Jul 20, 2023

Can I Recover Files Deleted over 90 Days Ago from OneDrive

Can you recover files deleted over 90 days ago from OneDrive? If you deleted some files from OneDrive and the recycle bin emptied, don't worry. It's possible to recover them. Read on to learn detailed information.


Jul 20, 2023

How to Remove Game Title in Steam Library After Being Deleted

How to remove game title in Steam Library after being deleted? This article will tell you how to remove the game title after being deleted. And if you accidentally deleted your Steam games, you can use EaseUS Data Recovery Wizard to recover the deleted game data.


Jul 20, 2023