Goto doesn't work! URGENT!!

Closed
mikrofarkost - Jun 8, 2010 at 12:50 AM
 mikrofarkost - Jun 8, 2010 at 08:27 AM
Hello, I'm makin a bat file wich should accomplish certain tasks,
like to start the defrag program after a certain number of seconds.
I have for this reason made two bat files. (becuse otherwise, it will be quite
much text in one of them.) one called X.bat, becuse, I didn't have a better name at
the moment, and one Close.bat, which perform taskkill.

now, in Close.bat you are to input numbers, which will then perform taskkill on
the program selected. It doesn't work. I tried to make a pause before the command taskkill
but the cmd just closed. again.

then, I'm not entiarly shure that my X.bat works properly.

1. could you look at my X.bat code and check if anything's wrong?
2. could you find out whats wrong with Close-bat?

(this program is supposed to be ran on a XP, Vista and a 7.)

Thank you for all answears!

X.bat CODE:

@echo off
setLocal EnableDelayedExpansion

cls
:start
ECHO.
ECHO 1. Abort shutdown
ECHO 2. Shutdown
ECHO 3. Close application
ECHO 4. Defrag (WARNING: will lock a Vista computer, for user verification)
ECHO.
ECHO If you'd like to terminate this program, press ctrl+c
set choice=
set /p choice=
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto Abort
if '%choice%'=='2' goto shut
if '%choice%'=='3' goto Close
if '%choice%'=='4' goto defrag
ECHO "%choice%" is not valid please try again
ECHO.
goto start

:shut
cls
set /p X=How long would you like to wait, before shutdown?
:loop
set /a N+=1
if !N! gtr !X! goto end
PING 127.0.0.1 -n 2
goto loop

:Close
@ start Close.bat
goto endend

:Abort
@ start shutdown.exe -a
goto endend

:endend
EXIT

:defrag
cls
set /p X=How long would you like to wait, before Defrag start?
:loop
set /a N+=1
if !N! gtr !X! goto loop
PING 127.0.0.1 -n 2
goto loop

:loop
set /a N+=1
if !N! gtr !X! goto program
PING 127.0.0.1 -n 2
goto loop

:program
cls
@ start /WAIT dfrgui.exe
goto end

:end
@ start shutdown.exe -s -t 0 -f
EXIT

Close.bat CODE:

@ ECHO off
cls
:start
ECHO.
ECHO 1. Internet Explorer
ECHO 2. Open office Writer
ECHO 3. Open office Draw
ECHO 4. Open office Calc
ECHO 5. Open office Base
ECHO 6. Open office impress
ECHO 7. Open office math
ECHO 8. Open office web
ECHO 9. Open office Main menu
ECHO 10. Google Earth
ECHO 11. Paint
ECHO 12. Windows Media Player
ECHO 13. User interface (restarts. NOT REKOMMENDED WHEN
ECHO RUNNING UNSAVED IMPORTANT DOCUMENTS)
set choice=
set /p choice=
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto internetex
if '%choice%'=='2' goto oow
if '%choice%'=='3' goto ood
if '%choice%'=='4' goto ooc
if '%choice%'=='5' goto oob
if '%choice%'=='6' goto ooi
if '%choice%'=='7' goto oom
if '%choice%'=='8' goto ooweb
if '%choice%'=='9' goto oomm
if '%choice%'=='10' goto googearth
if '%choice%'=='11' goto paint
if '%choice%'=='12' goto WMP
if '%choice%'=='13' goto Explorer
ECHO "%choice%" is not valid please try again
ECHO.
goto start

:internetex
TASKKILL -f /im iexplore.exe
goto end

:oow
TASKKILL -f /im swriter.exe
goto end

:ood
TASKKILL -f /im sdraw.exe
goto end

:ooc
TASKKILL -f /im scalc.exe
goto end

:oob
TASKKILL -f /im sbase.exe
goto end

:ooi
TASKKILL -f /im simpress.exe
goto end

:oom
TASKKILL -f /im smath.exe
goto end

:ooweb
TASKKILL /im sweb.exe
goto end

:oomm
TASKKILL -f /im soffice.exe
goto end

:googeearth
TASKKILL -f /im googleearth.exe
goto end

:paint
pause
TASKKILL -f /IM mspaint.exe
goto end

:WMP
TASKKILL -f /im wmplayer.exe
goto end

:Explorer
TASKKILL -f /im explorer.exe
PING 127.0.0.1 -n 2
@ start explorer.exe
goto end

:end
EXIT


Related:

1 response

Noooo!!!!! I had to re-make the file for some reason, so I copyed my previous
code from here. Now x.bat ALSO terminates after input + enter.
I need help!
0