Page 1 of 1

IF STATEMENT DOESNT RUN

Posted: 05 Jan 2012 06:14
by kivifreak
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

Re: IF STATEMENT DOESNT RUN

Posted: 11 Jan 2012 00:11
by Cat
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

Re: IF STATEMENT DOESNT RUN

Posted: 11 Jan 2012 08:01
by Squashman
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.

Re: IF STATEMENT DOESNT RUN

Posted: 11 Jan 2012 10:48
by Ed Dyreen
'
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.