Run a batch file when folder is opened




















Yes, this is possible, thanks to the magic of WMI events, which allow you to write a script to monitor for something of interest like a file being added to a folder and then take some action any time an event like that occurs. Consequently, it might be worth your while to check out this Tales from the Script column. Any time a file is added to this folder, the script responds by echoing the name of that new file:.

Keep in mind two things, however. Conversely, if you make the value too long, you might miss new files, assuming they get added and then deleted before the polling time expires. For example, say your script checks every 5 minutes for new files.

If you add new files and then delete all those files 3 minutes later, the script will never know that those files were added to the folder. Play around with the polling interval and see what works best for you. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta.

New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions. Since you know when the file gets updated? Why not reload it then using a scheduled task? Otherwise you can: Schedule the batch file 15 mins should be could In the batch file check the current modified date of the file against what is written in another file eg modified.

If it's different, reload. Overwrite the last modified time in modified. Nig Mar 14, at UTC. Thank you for the reply, i already auto refresh via a code in PHP, so every 15 minutes the page refreshes, but what i want to do is if you add the file manually the system instantly refreshes the page for instance, my page shows people, and as people move it updates every 15 minutes but if i needed to let everyone know of something ASAP via this system i want to overwrite the file, then the batch file runs and refreshes the page straight away rather than wait 15 minutes hope this makes sense.

Pure Capsaicin. Martin This person is a verified professional.



0コメント

  • 1000 / 1000