Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I'm a newb at programming and stuff but I just want to know the best way to go about this.
Basically, I have an application. What I want to happen is run a script of some sort that launches this application (like a shortcut would). Then when the application closes I want the script to detect this, then delete some folders that have been created by the application and then close itself.
Can I do this with a batch file or do I need to go more in-depth? Any help would be appreciated. Thanks!

To wait for an application to exit and then delete files from a folder:
start/wait application.exe
del C:\path\to\folder

myprog.exe
rd /s /q x:\thestuff
=====================================
If at first you don't succeed, you're about average.M2

Ok, with two answers, the original poster must be wondering who's right. If the application is a console application, then M2's simple "myprog.exe" is good. If it is a Windows application, the batch file will not wait for it to finish, but will start executing the next line immediately. That's why I used the "start/wait" command. M2, you're correct with the "rd/s /q" command to delete a folder: mine only deletes files within the folder, which is not what was asked.

Hi klint,
I dunno console app, but it waits for excel.
::===================================
"D:\Program Files\Microsoft Office\Office\EXCEL.exe"
echo hi
=====================================
If at first you don't succeed, you're about average.M2

Excellent, thanks very much, it worked a treat. I used klint's start/wait command and Mechanix2Go's rd command successfully. It didn't actually work to begin with but then I realised because I was deleting folders inside Documents and settings I needed to put the entire path in quotes, then it worked.
Anyway thanks very much!

You're right again, M2. When I tested it, it didn't wait, but I was typing it directly on the command line. If you do it in a batch file, it waits.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |