batchfile command, unexpected error

July 4, 2005 at 07:47:13
Specs: W2000 SP4, 2 GB

Running a batchfile with the following entry gives an error.

SET CTIME = %TIME:~0,2%
rem **this sets the variable ctime to the hour portion of the time, example 17 or 23

IF %CTIME% = 13
= was unexpected at this time.

Any idea?

W. Vanpeel


See More: batchfile command, unexpected error

Report •


#1
July 4, 2005 at 14:10:01

Hi
You need two equal signs.
IF %CTIME%==13


Report •

#2
July 5, 2005 at 00:09:14

Hi,
thx, but still the same error.
I tried
IF %CTIME%==13
IF %CTIME==13
IF %CTIME=13

All give the same error or syntax error.
CTIME variable is OK
SET command lists also CTIME=13

Rgds


W. Vanpeel


Report •

#3
July 5, 2005 at 10:37:41

Hi
That should work, you could try
if %ctime% EQU 13
but what is code doing with the if statement.


Report •

Related Solutions

#4
July 5, 2005 at 10:57:10

For some reason, this will not run correctly with spaces before or after the "=".

This seems to run OK:

SET CTIME=%TIME:~0,2%
IF %CTIME%=="13" ECHO MATCH!!
IF NOT %CTIME%=="13" ECHO NO MATCH!!


Rule #1 Good computers don't go down.
Rule #2 There is no such thing as a good computer.


Report •

#5
July 6, 2005 at 00:32:41

This works, good stuff.
Thx Rick

W. Vanpeel


Report •


Ask Question