RUN Windows Media with VBscript and Perl: checkWMCmd.bat
Thursday, October 7, 2010 4:33:34 PM
@echo off
:: check if it's time to insert CF
SET INSERTORNOT=
for /f "tokens=1 usebackq" %%A in (`perl checktime.pl`) do (SET INSERTORNOT=%%A)
if "%INSERTORNOT%" == "INSERTNOW" goto INSERTNOW
if "%INSERTORNOT%" == "INSERTEND" goto INSERTEND
goto REGULARCHECK
:INSERTNOW
taskkill /f /im cscript.exe
cscript WMCmd.vbs -wme insert.wme
goto EXIT
:INSERTEND
taskkill /f /im cscript.exe
:REGULARCHECK
:: start checking whether cscript exists in tasklist!!
SET THETASK=
for /f "skip=2 tokens=1 usebackq" %%A in (`tasklist /fi "imagename eq cscript.exe"`) do (SET THETASK=%%A)
if not "%THETASK%" == "cscript.exe" goto DOWN
goto EXIT
:DOWN
:: print out down time to error log and restart cscript...
for /f "tokens=1-2 usebackq" %%A in (`date /T`) do (SET NOWDATE=%%A %%B)
for /f "tokens=1-2 usebackq" %%A in (`time /T`) do (SET NOWTIME=%%A %%B)
echo %NOWDATE% %NOWTIME% cscript.txt restarts...>> checktaskerr.txt
cscript WMCmd.vbs -wme default.wme
:EXIT
echo exiting...
:: check if it's time to insert CF
SET INSERTORNOT=
for /f "tokens=1 usebackq" %%A in (`perl checktime.pl`) do (SET INSERTORNOT=%%A)
if "%INSERTORNOT%" == "INSERTNOW" goto INSERTNOW
if "%INSERTORNOT%" == "INSERTEND" goto INSERTEND
goto REGULARCHECK
:INSERTNOW
taskkill /f /im cscript.exe
cscript WMCmd.vbs -wme insert.wme
goto EXIT
:INSERTEND
taskkill /f /im cscript.exe
:REGULARCHECK
:: start checking whether cscript exists in tasklist!!
SET THETASK=
for /f "skip=2 tokens=1 usebackq" %%A in (`tasklist /fi "imagename eq cscript.exe"`) do (SET THETASK=%%A)
if not "%THETASK%" == "cscript.exe" goto DOWN
goto EXIT
:DOWN
:: print out down time to error log and restart cscript...
for /f "tokens=1-2 usebackq" %%A in (`date /T`) do (SET NOWDATE=%%A %%B)
for /f "tokens=1-2 usebackq" %%A in (`time /T`) do (SET NOWTIME=%%A %%B)
echo %NOWDATE% %NOWTIME% cscript.txt restarts...>> checktaskerr.txt
cscript WMCmd.vbs -wme default.wme
:EXIT
echo exiting...






