IF STATEMENT DOESNT RUN

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
kivifreak
Posts: 1
Joined: 05 Jan 2012 06:05

IF STATEMENT DOESNT RUN

#1 Post by kivifreak » 05 Jan 2012 06:14

I Have a problem with the if statement, it automatically ends the code... thx for help :)
@echo off
color A
:n
echo Program Name:
set /p a=
set /a X=0
echo
echo Please write your program here:
:run
set /a X=%X%+1

set /p li=%X%

(%li%)>>%a%.bat
if /i "%li%" EQU "exit"(goto :exit)
goto :run
:exit

cls
echo making in progress.
PING 1.1.1.1 -n 1 -w 1000 >NUL
cls
echo making in progress..
PING 1.1.1.1 -n 1 -w 1000 >NUL
cls
echo making in progress...
PING 1.1.1.1 -n 1 -w 1000 >NUL
cls
echo File %a%.bat was made succesfully...
pause
echo You want to run it (y/n) ?
set /p jea=
if /i "%jea%"=="y"(
echo Your Programm %a%:
echo ----------------------------------------------------
call %a%.bat
pause

)
exit

Cat
Posts: 32
Joined: 11 Nov 2011 12:04

Re: IF STATEMENT DOESNT RUN

#2 Post by Cat » 11 Jan 2012 00:11

Try this:

Code: Select all

@echo off&color A
:n
set /p a="Program name:"&set /a X=1
echo\&echo Please write your program here:
:run
set /a X+=1
set /p li=%X%
echo.%li%>>%a%.bat
if /i "%li%" EQU "exit"(goto :exit)
goto run
:exit
cls&echo making in progress...
timeout /t 3 /nobreak>nul&cls
echo File %a%.bat was made succesfully...
pause
choice /m "You want to run it"
if  "%errorlevel%"=="y" (
echo Your Programm %a%:
echo ----------------------------------------------------
call %a%.bat
pause
)
exit

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: IF STATEMENT DOESNT RUN

#3 Post by Squashman » 11 Jan 2012 08:01

Just a notice for the original poster, TIMEOUT and CHOICE are not native to Windows XP. You may have issues running the script Cat posted. Those commands are available on Vista and Windows 7.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: IF STATEMENT DOESNT RUN

#4 Post by Ed Dyreen » 11 Jan 2012 10:48

'
Squashman wrote:Just a notice for the original poster, TIMEOUT and CHOICE are not native to Windows XP. You may have issues running the script Cat posted. Those commands are available on Vista and Windows 7.
choice can be downloaded, timeout can be replaced in several ways, the easiest being ping /?.

Code: Select all

ping 0.0.0.0
http://www.dostips.com/forum/viewtopic.php?f=3&t=1893&start=0
You can follow this link which leads to my domain, there you'll find choice as part of eDOS. Or you could try to google yourself.

Post Reply