# DOS is hard



## Bloodyskullz (Oct 12, 2006)

Well at least to me. Currently I am trying to create a batch file called START1.bat where I am todo the following instructions:

a: Clear the Screen and output the message of Opening.TXT (completed)
b: Give the Choiceof ending the batch file or "Viewing my Directory" using the ^C and Pause. Make sure te appropriate prompting messages to make this "user friendly." The batch file should display the current directory if the user chooses to do so.

This is what I have so far (from using NOTEPAD):

CLS

@ECHO OFF

ECHO Hi! My name is CROC, (short for microcomputer)
ECHO.
ECHO I hope you will enjoy using me, (most people don't like being "used" but machines love it)
ECHO.
ECHO I will try and make it as easy as possible for you to get to know me and use me by prompting you with messages and waiting for you to respond.
ECHO.
ECHO Do you wish to end the batch file or view directory?

%1 
%2 PAUSE

From the check list must do the directory part etc. I know the command for the directory is DIR.

Please help me.


----------



## JohnWill (Oct 19, 2002)

The command is simply DIR if you want to display the current folder where you've run the batch job from.


----------



## Bloodyskullz (Oct 12, 2006)

I know that part but I need help in typing the command to give it the choice of DIR or exit.


----------



## JohnWill (Oct 19, 2002)

You probably need a 3rd party utility, since the CHOICE command was removed from XP. OTOH, you mentioned Ctrl-C at the PAUSE. If you Ctrl-C and say yes to the abort, the commands following the PAUSE won't execute, which is what I thought you were intending.

Here's a Treasure-Trove of MS-DOS batch utilities, many options: http://garbo.uwasa.fi/pc/batchutil.html


----------



## Bloodyskullz (Oct 12, 2006)

JohnWill said:


> You probably need a 3rd party utility, since the CHOICE command was removed from XP. OTOH, you mentioned Ctrl-C at the PAUSE. If you Ctrl-C and say yes to the abort, the commands following the PAUSE won't execute, which is what I thought you were intending.
> 
> Here's a Treasure-Trove of MS-DOS batch utilities, many options: http://garbo.uwasa.fi/pc/batchutil.html


Link doesnt work.


----------



## Squashman (Apr 4, 2003)

Bloodyskullz said:


> Link doesnt work.


Works just fine.


----------



## ghostdog74 (Dec 7, 2005)

there's no need to go for any third party tools or whatsoever, if you are on XP. you can use set with /p option.

```
SET /P var="do you want to view directory or quit"
```
then use the if command to check the variable var. 
for more information, type set /? , if /? on the command prompt.
btw, you will most often need for loop as well, so type for /? also for more info.


----------



## JohnWill (Oct 19, 2002)

ghostdog74, you're right!  I never needed it, and I always wondered why the CHOICE command was removed. This is obviously the replacement.


----------



## Bloodyskullz (Oct 12, 2006)

Thanks guy everything worked out great. I will get help from you guys for any other DOS problems I get. Keep this topic open.


----------



## ghostdog74 (Dec 7, 2005)

JohnWill said:


> I always wondered why the CHOICE command was removed.


same here...the choice command, if anyone still wants to use that , can be downloaded as well. I think it has more options than what set /p can offer, but then again , i seldom use it too, so ...


----------



## JohnWill (Oct 19, 2002)

Interesting, where do you download the CHOICE command? I was surprised it was gone.


----------



## ghostdog74 (Dec 7, 2005)

Here. Note there's 2 of them, choice.exe and choice.com...


----------



## JohnWill (Oct 19, 2002)

Great.  I did a Google search and didn't come up with them. I need to sharpen my "google pen".


----------



## Bloodyskullz (Oct 12, 2006)

Ok. Guys I need some more help with another Batch file. Here is what I have so far:

@ECHO OFF
cls

ECHO A. C:\
ECHO B. C:\WINDOWS
ECHO C. A:\
SET /P USERINPUT=Type A,B, or C to go to directories.
IF '%USERINPUT%'=='A'GOTO A
IF '%USERINPUT%'=='a'GOTO A
IF '%USERINPUT%'=='B'GOTO B
IF '%USERINPUT%'=='b'GOTO B
IF '%USERINPUT%'=='C'GOTO C
IF '%USERINPUT%'=='c'GOTO C

:A
ECHO You are now in C:\ directory.
DIR C:\
C:
GOTO END

:B
ECHO You are now in C:\WINDOWS directory.
DIR C:\WINDOWS
C:
CD WINDOWS
GOTO END

:C
ECHO You are now in A:\ directory.
DIR A:\
A:\
GOTO END

:END

I am suppose to have the options to go to any of the directories but for some reason evreytime I press the diretory i want it goes only to c:\ Can you guys help?


----------



## Bloodyskullz (Oct 12, 2006)

Can anyone help?


----------



## JohnWill (Oct 19, 2002)

Remote all the quotes around the choices.


----------



## Bloodyskullz (Oct 12, 2006)

JohnWill said:


> Remote all the quotes around the choices.


What does that mean?


----------



## goldhat (Aug 12, 2007)

it means this

@ECHO OFF
cls

ECHO A. C:\
ECHO B. C:\WINDOWS
ECHO C. A:\
SET /P USERINPUT=Type A,B, or C to go to directories.
IF "%USERINPUT%"=="A" GOTO A
IF "%USERINPUT%"=="a" GOTO A
IF "%USERINPUT%"=="B" GOTO B
IF "%USERINPUT%"=="b" GOTO B
IF "%USERINPUT%"=="C" GOTO C
IF "%USERINPUT%"=="c" GOTO C

:A
ECHO You are now in C:\ directory.
DIR C:\
C:
GOTO END

:B
ECHO You are now in C:\WINDOWS directory.
DIR C:\WINDOWS
C:
CD WINDOWS
GOTO END

:C
ECHO You are now in A:\ directory.
DIR A:\
A:\
GOTO END

:END

but with that code it will display the directories and file then exit


----------



## JohnWill (Oct 19, 2002)

Actually, you don't need the double quotes either, just take them all out. This isn't C++, it's a simple batch language.


----------

