How can I automatically erase/edit the content of a text file everytime it is updated?

I am running an application that writes into a text file.

I would like to have a batch file or any other tool that helps me to edit this file (or erase the content of this text file) every time it is updated by the application.

Any ideas?  Thx
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

To the best of my knowledge, there are no "events" available for file system objects in any version of windows, so the best you'll be able to do here is write a script file that checks for the existance of the file, and deletes/edits it, and then schedule that script to run periodically.  There may be third party programs that claim to do what you're asking, but they're likely just doing the same thing...periodically checking for the file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
you can do such a thing by writing a mini c++ program. by using a hook that will check if the file is accessed for write.
True, C++ program would be the most efficient and fun to write, but you can also write a simple Visual Basic application which runs in the background (hide its window, and/or minimize it to the system tray).  For the most part, it sleeps.  But every few seconds, it wakes up, looks at the file last-modified date.  If it has changed since the last time it looked at it, erase the file.

One problem to be aware of, is what might happen when your existing application tries to open the file for writing while this new application has it open for clearing.

Can you pipe the output in NUL? Then the file won't even be created.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 2000

From novice to tech pro — start learning today.