0

I am trying to write some code to a VBS file through batch. Everything works fine except

echo if(Time()>TimeValue("8:30am") and Time()<TimeValue("3:15pm")) then >> 

This is among other echos to this file like

echo do >> %APPDATA%\tbwg22f.vbs
echo if(Time()>TimeValue("8:30am") and Time()<TimeValue("3:15pm")) then >> %APPDATA%\tbwg22f.vbs
echo Dim message, sapi >> %APPDATA%\tbwg22f.vbs

The if(Time) line won't echo to my VBS file but all the other ones do

phuclv
  • 37,963
  • 15
  • 156
  • 475
harrison
  • 19
  • 1
  • 1
  • 8

1 Answers1

0

(, ), > are special characters to the shell. You need to escape them to print as a literal string

echo if^(Time^(^)^>TimeValue("8:30am") and Time^(^)^<TimeValue^("3:15pm"^)^) then >> 
phuclv
  • 37,963
  • 15
  • 156
  • 475