Error in If logic
Posted: 01 Apr 2010 12:33
The below piece of code keeps erroring out saying "8 was unexpected at this time." anb its poiting to this line : "if %var1:~1,8% NEQ Disabled". Any thoughts? Very strange thing is it works sometimes... I have seen it work many times and it has given error also many times... Its the same piece of code no change was done during both success and error.
@Echo off
if %date:~0,3% EQU Sat if %time:~0,2% EQU 10 (
schtasks /query | find /i "pdh_load_n_start_new_batches" > E:\PDH_Archive\SchStat.txt
for /f "tokens=2-3" %%# in ('type E:\PDH_Archive\SchStat.txt') do set var1= %%#
echo %var1%
if %var1:~1,8% NEQ Disabled (
echo Schedled task is not disabled. Will be disabling task now
)
)
@Echo off
if %date:~0,3% EQU Sat if %time:~0,2% EQU 10 (
schtasks /query | find /i "pdh_load_n_start_new_batches" > E:\PDH_Archive\SchStat.txt
for /f "tokens=2-3" %%# in ('type E:\PDH_Archive\SchStat.txt') do set var1= %%#
echo %var1%
if %var1:~1,8% NEQ Disabled (
echo Schedled task is not disabled. Will be disabling task now
)
)