Page 1 of 1

are batch file writing different in windows xp and dos 7.1

Posted: 23 Jun 2010 00:43
by flyhigh427
when i run this bat file in windows command prompt it works fine when i run it from dos 7.1 prompt i get syntex errors
anyone know why?
thanks


Code: Select all

@echo off



:start
cls
echo Input password:

IF %DATE:~0,3%==Mon goto mond
IF %DATE:~0,3%==Tue goto tues
IF %DATE:~0,3%==Wed goto wedd
IF %DATE:~0,3%==Thu goto thur
IF %DATE:~0,3%==Fri goto frid
IF %DATE:~0,3%==Sat goto sate
IF %DATE:~0,3%==Sun goto sund



Re: are batch file writing different in windows xp and dos 7

Posted: 23 Jun 2010 03:26
by amel27
DOS not support environment variables DATE and TIME, only NT
this code work for me, DATE format: "Current date is Wed 06-23-2010"

Code: Select all

@echo on

echo.|date|find /i "sat"|if not errorlevel 1 >nul goto sate
echo.|date|find /i "sun"|if not errorlevel 1 >nul goto sund
echo.|date|find /i "mon"|if not errorlevel 1 >nul goto mond
echo.|date|find /i "tue"|if not errorlevel 1 >nul goto tues
echo.|date|find /i "wed"|if not errorlevel 1 >nul goto wedd
echo.|date|find /i "thu"|if not errorlevel 1 >nul goto thur
goto frid