REM All this gets done if the file exists. IF NOT EXIST C:\SOMEWHERE\SUBFOLDER\THISFILE.THS EXIT 1 cmd file on a regular basis and that file could start with a line to check for the existence of the required file - in fact, I'd check for the non existence of the file for example: OFF You seem to be on the right lines - you could use the task scheduler to run a. (Also, I don't want to leave this question officially unanswered - and I hate to accept my own answer to the question - but I did upvote Linker3000's answer as a thanks!) StrTempFilePath = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) & "\TEMP.M4A" StrFileName = Replace(strFilePath, strFolder, "") StrFilePath = Replace(strFilePath, Chr(34), "") StrFilePath = Replace(strFilePath, "\\", "\") Set objLatestEvent = colMonitoredEvents.NextEvent Set colMonitoredEvents = objWMIService.ExecNotificationQuery ("SELECT * FROM _InstanceCreationEvent WITHIN " & nFrequency & " WHERE Targetinstance ISA 'CIM_DirectoråontainsFile' and TargetInstance.GroupComponent='Win32_Directory.Name=""" & strQueryFolder & """'") $action = !\\" & strComputer & "\root\cimv2") # DEFINE ACTIONS AFTER AN EVENT IS DETECTED $watcher = New-Object System.IO.FileSystemWatcher StartMonitoring.ps1 # SET FOLDER TO WATCH + FILES TO WATCH + SUBFOLDERS YES/NO
![script to monitor folder for new files windows script to monitor folder for new files windows](https://kevinholman.com/wp-content/uploads/2018/12/image-605.png)
19:22:14, Deleted, D:\source\New Text Document.txt 19:22:09, Changed, D:\source\New Text Document.txt 19:22:04, Created, D:\source\New Text Document.txt You can replace the action and do whatever you want e.g call an external tool Example log file This script monitors a certain folder and writes a logfile.
![script to monitor folder for new files windows script to monitor folder for new files windows](http://4.bp.blogspot.com/-PqqpFihXx_k/TqmRZi197lI/AAAAAAAAOpk/dc0b-K2HPs8/s1600/ScreenShot430.jpg)
#Script to monitor folder for new files windows windows#
It can be used since Windows Vista (.NET and PowerShell is preinstalled) without any additional tools. At work we use Powershell to monitor folders.