I handle this a little differently, in my case I leave the rule in there which always runs a script (cam2detect.bat), but drop or delete another file (on.txt) to control whether the script continues execution or not. For example...
---------------------------------------------------------------------------------------------------
cam2detect.bat...
@ECHO OFF
IF NOT EXIST C:\SWMON\on.txt goto done
:run
START "cam2run" /D "C:\SWMON" "C:\SWMON\cam2run.bat"
:done
EXIT
REM This script is configured to run, under each camera rule, in VDV
---------------------------------------------------------------------------------------------------
cam2run.bat...
@ECHO OFF
CD\
CD C:\SWMON
IF EXIST C:\SWMON\marker-cam2lockout.txt goto lockout
ECHO %DATE% %TIME% Lockout >> C:\SWMON\marker-cam2lockout.txt
ECHO %DATE% %TIME% VDV Motion on cam2 >> C:\SWMON\sys-log.txt
SLEEP 1
C:\SWMON\sendEmail.exe -f
[email protected] -t
[email protected] -u "cam2 motion detected" -m "VDV running on servername detected cam2 motion." -s smtp.example.com
"C:\Program Files\VideoLAN\VLC\vlc.exe" file:///C:\SWMON\sound\motiondet.wav
vlc://quitSLEEP 20
DEL C:\SWMON\marker-cam2lockout.txt
goto done
:done
EXIT
:lockout
EXIT
:faulterr
ECHO %DATE% %TIME% cam2run error >> C:\SWMON\sys-log.txt
EXIT
REM This script runs only if the system is on
---------------------------------------------------------------------------------------------------
P.S. My real script is a little more complex cause it's integrated with a home automation / alarm system. For example, I've configure on.txt to get created when the homeowner turns the alarm system on (keyswitch or numberpad hardware), and it gets deleted when the alarm system is disarmed. Sometimes I will also configure the second batch file grab 3 still .jpg's from the IP camera and attach them to the email, so the homeowner has an idea of if it's a false alarm/someone they know vs. an intruder such that it's worth using RDP to go into the system and check.