Solved input to start a program not working...

February 9, 2012 at 17:00:25
Specs: Windows Vista
I have made a code that is supposed to start a different program on when you input what day of the week it is, but it doesn't run them when I want them too, Please may someone help me?
The code is this:

@echo off
cd RosaryMysteries
title Rosary
color 1e
:start
echo The Rosary
echo.
pause

goto choice

REM joyful
:joyful
start joyful.bat
exit

REM sorrowful
:sorrowful
start sorrowful.bat
exit

REM luminous
:luminous
start luminous.bat
exit

REM glorious
:glorious
start glorious.bat
exit

REM choice
:choice
cls
set /p day = What is the day of the week today? (No caps please)
if /i {%day%}=={monday} then goto :joyful
if /i {%day%}=={tuesday} then goto :sorrowful
if /i {%day%}=={wednesday} then goto :glorious
if /i {%day%}=={thursday} then goto :luminous
if /i {%day%}=={friday} then goto :sorrowful
if /i {%day%}=={saturday} then goto :joyful
if /i {%day%}=={sunday} then goto :glorious


See More: input to start a program not working...

Report •


#1
February 10, 2012 at 03:06:30
✔ Best Answer
Replace (the same for each IF statement)

if /i {%day%}=={monday} then goto :joyful

with

if /I "%day%"=="monday" goto :joyful

and avoid spaces around = in SET statements, i.e.

set /P day=What is the day of the week today? (No caps please)^>

By the way the /I switch of IF statement forces to ignore upper/lower case. More to launch the selected batch and exit just code, e.g.

joyful

not

start joyful.bat
exit

The above leads to a straightforward code as

if /I "%day%"=="monday" joyful

I can send you a little program to autodetect the day of the week without prompting the user. If interested contact me by a private message reporting your e-mail address.

Report •

#2
February 11, 2012 at 06:42:09
Thanks! :-)

Report •

Related Solutions


Ask Question