batch menu problem

December 23, 2009 at 10:13:15
Specs: Windows XP
hi, im tring to make a batch private IM using the msg command. the menu i designed around it works, execpt for a few parst...when you send the message, it jumps to the label :menu (which is several labels before). and if you answer with two or more words for the password or message it terminates. can some one help me solve this please?
heres the script:

@echo off
color 09
title Private IM - Name
set answer=abcd
echo please enter your initials.
set /p name=

title Private IM - Menu
echo welcome to private IM.
echo to start your session please type your password.
set /p input=
if not %input% == %answer% goto wrong
echo correct!
echo welcome %name%.
echo what user do you want to connect with?
set /p user=

echo session: %name% to %user% at %date% %time%
title Private IM - %name% to %user% at %date% %time%
echo type your message to %user%.
set /p msg=
if %msg% == leave exit

msg %user% /w %msg%
goto session

color 0c
echo im sorry, that is the wrong password. try again later.

echo goodbye

the main probelms are it won't accept two word answers and it skips to a random place unexpectedly.
to help solve i suggest copying the script into a new batch and editing from there. that how i do it. :)


See More: batch menu problem

Report •

December 23, 2009 at 10:33:57
Close your strings in quotes and lose the spaces.

if "%var%"=="zzz" blabla

Also, :exit is never used. May not hurt but surely adds to confusion.

Helping others achieve escape felicity


Report •

December 23, 2009 at 10:43:02
It also wouldn't hurt to use:


Instead of:


To avoid the if statement getting killed if the var contains double quotes.

Batch Variable how to

Report •

December 23, 2009 at 13:27:10
if %msg% == leave exit

is missing a GOTO command, unless "EXIT" is a command you want to run

(and as Mechanix stated: IF "%var%"=="something" ... it will ALWAYS work if you use double-quotes, without, you're taking risks)

... and, whenever a script does not work, and you don't know what happens : "echo off" -> "echo on"

Report •

Related Solutions

Ask Question