Computing.Net > Forums > Programming > DOS batch files question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS batch files question

Reply to Message Icon

Name: DOS n00b
Date: March 15, 2005 at 05:00:37 Pacific
OS: Win XP
Comment:

Hi,

i'll try and explain my problem:
i've created a nice menu in DOS using batch files. there is only one problem. when i want to exit my menu there's a problem.

on boot i call the autoexec.bat (main menu) from here you can make choises. if you choose an advanced option you will be promted if you want to continue (**), if you choose "no" you will return to the main menu (i do this by calling the autoexec again). if you then choose exit in the main menu the following happends:

the procedure (**) if you choose continue will start.


i think my problem is that i have several batchfiles running at the same time, so when i close one of them the other one continues. but the thing is that i used the command: "exit" after every option. or should i have used another command to close the current batchfile??

hope i was able to explain my problem
plz help me

An enemy is not to be underestimated.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 15, 2005 at 05:17:19 Pacific
Reply:

"on boot i call the autoexec.bat"

I don't know of any way to NOT run autoexec.bat at boot.

It would help to say what version of DOS you are using.

Also helpful to post your batch.

Use Dr Nick's wonderful CODEPOST utility to get your batch in shape so that it displays properly.

http://students.cs.byu.edu/~drnick/entityrecode.html

M2


0

Response Number 2
Name: DOS n00b
Date: March 15, 2005 at 05:27:59 Pacific
Reply:

ok, i'll try that,
DOS v6.0... here's an example of what i use:
______________________________
option 1
option 2

Cmd\choice /c12]/N
if errorlevel 2 goto :ToMain
if errorlevel 1 goto :CrtFac

:ToMain
echo Back to the main menu
CALL autoexec.bat
exit

:CrtFac
echo Create Factory Back-Up
CALL ghost\ghost.exe -clone,mode=pdump,src=1:1,dst=C:\Images\Factory.gho -Z9 -sure -cns
goto :Quit

:Quit
echo Quit
CALL Quit.bat
exit
______________________________

the autoexec will be run, i choose the option to create a factory image, i decide i dont want to create one. i go back to the main menu and i want to exit the entire process.
while exiting the :CrtFac will begin.

An enemy is not to be underestimated.


0

Response Number 3
Name: Mechanix2Go
Date: March 15, 2005 at 06:04:59 Pacific
Reply:

Hi,

Well if that's actual code, I'm pretty much lost.

Are these comments:

option 1
option 2

If not, what do they do?

CMD is neither an internal DOS command nor a standard part of a DOS installation. So what is it?

If you want to ECHO a msg, you first turn echo off.

Many batch writers always put this as a first line.

@echo off

I usually use:

@echo off > quit.bat

which gives me a 'hasty exit'.

I would avoid at all costs CALLing or doing anything with autoexec.bat; it's a recipe for trouble.

You do not need to CALL an EXE. CALL is to run another batch and return control to the CALLing batch.

In this bit:

::**
goto :Quit

:Quit
echo Quit
CALL Quit.bat
::**
the goto doesn't seem very useful because where it's 'going' is the next line down.

M2


0

Response Number 4
Name: DOS n00b
Date: March 15, 2005 at 06:16:31 Pacific
Reply:

ok my bad, should have explained better, lemme work those things out and i'll try to understand what you said:
_________________________________
@echo off
CLS

echo.
echo.
echo 1 Create a factory image
echo 2 Resturn to main menu

choice /c12]/N
if errorlevel 2 goto :ToMain
if errorlevel 1 goto :CrtFac

:ToMain
echo Back to the main menu
CALL MainMenu.bat
exit

:CrtFac
echo Create Factory Back-Up
ghost\ghost.exe -clone,mode=pdump,src=1:1,dst=C:\Images\Factory.gho -Z9 -sure -cns
CALL Quit.bat

An enemy is not to be underestimated.


0

Response Number 5
Name: Mechanix2Go
Date: March 15, 2005 at 06:29:34 Pacific
Reply:

Hi nOOb,

That looks a whole lot better.

Is it working or have you got some remining rough spots?

M2


0

Related Posts

See More



Response Number 6
Name: DOS n00b
Date: March 15, 2005 at 06:47:39 Pacific
Reply:

tnx :) it looks a lot better now but i still have the following problem:

mainmenu.bat is run --> advanced option is chosen --> return to mainmenu.bat --> exit the menu --> create factory image starts.
(the :CrtFac option)

do you know how to end the batch file before the :CrtFac thing starts?

An enemy is not to be underestimated.


0

Response Number 7
Name: Mechanix2Go
Date: March 15, 2005 at 07:15:07 Pacific
Reply:

Hi,

If this:

ghost\ghost.exe -clone,mode=pdump,src=1:1,dst=C:\Images\Factory.gho -Z9 -sure -cns

is all one line. [I guess it is]

And if your quit.bat 'does nothing' like mine. Then there's probably no good reason to return to the batch.

In that case eliminate the line:

CALL quit.bat

Then your last line, starting with:

ghost\ghost.exe

is the last thing the batch does.

It's done.

HTH

M2


0

Response Number 8
Name: DOS n00b
Date: March 15, 2005 at 07:25:44 Pacific
Reply:

tnx, it works :)

An enemy is not to be underestimated.


0

Response Number 9
Name: Mechanix2Go
Date: March 15, 2005 at 07:33:15 Pacific
Reply:

Good.

Glad it works.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: DOS batch files question

DOS Batch File Commands www.computing.net/answers/programming/dos-batch-file-commands/14637.html

Spilt a numeric value in dos batch file www.computing.net/answers/programming/spilt-a-numeric-value-in-dos-batch-file/19115.html

editing dos batch file www.computing.net/answers/programming/editing-dos-batch-file/20208.html