1.

Solve : adding a menu in a batch file?

Answer»

is there a way to add a menu where it says "file, edit, view" ect?
How would I make it?

Thanks
S_R_SNope
Batch is just a simple scripting language which primary function is to provide a way of executing a series of commands automatically. If you want to create real programs you will need to learn a programming language.But - you can use clever Prompt commands to put a menu bar across the top (or bottom) of the screen saying 1 file | 2 edit | etc etc
Then create a short batch called 1.bat that does the file stuff, 2. bat to do the edit stuff etc

GrahamI just do this--

Code: [Select]rem --Basic Menu--

echo 1. Edit
echo 2. Notepad
echo 3. Paint

choice.com /c:123 (1, 2, or 3)%1
if errorlevel == 3 then start paint
if errorlevel == 2 then start notepad
if errorlevel == 1 then goto editer
goto End

:editer
echo -- Starting Edit --
edit

cls
:End

it usually works for meAll well and good if you have Choice installed !

GrahamI thought MS-DOS came with it?

I am runing Win98' on my home comp (and it has no Internet)
The school I go to (where I post my messages, test stuff, etc. . .)
is usnig WinXP so I'm kinda screwed. . Win 98 (or 95 even) was probably the last time it was released as part on the os, certainly it was gone in win 2k

I know that you can grab it off an old win 3.11 disk or a replacement off the net somewhere.

But this is the 21st Century, we dont need no menus in batch, it really is the wrong language to be doing that, use an html application (.hta) for the ui if you are unable or prohibited from using a proper development environ and use batch for what its good at.

GrahamQuote from: Wolfmagi on December 20, 2007, 08:43:45 AM

I thought MS-DOS came with it?

It does.

Quote
I am runing Win98'

It does too.

Quote
on my home comp (and it has no Internet)
The school I go to (where I post my messages, test stuff, etc. . .)
is usnig WinXP so I'm kinda screwed. .

Depends on whether or not you can put a copy of choice in a directory in the path.

Or - learn the methods that can be used with XP. XP's command line has many capabilities that plain old dos did not. The way to do it has been covered many times here. You'll find it with a search.


Quote from: gpl on December 20, 2007, 09:39:51 AM
...
I know that you can grab it off an old win 3.11 disk or a replacement off the net somewhere.

I doubt it would have been on a Win3.11 disk. More likely, choice.com would have been installed with the MS-DOS installation prior to installing Windows.

Here is one place where choice can be downloaded:
http://hp.vector.co.jp/authors/VA007219/dkclonesup/choice.html

Quote
But this is the 21st Century, we dont need no menus in batch, it really is the wrong language to be doing that, use an html application (.hta) for the ui if you are unable or prohibited from using a proper development environ and use batch for what its good at.


While you might not absolutely need menus, there is nothing wrong with learning how it was done.

Besides - you never know when you just might need to know.

Quote from: WillyW on December 20, 2007, 10:23:04 AM

Besides - you never know when you just might need to know.


Oh so true !!

oops, just shows how long it is since windows was an app RUNNING on top of the OS, I had forgotten about loading DOS first.... or at least assumed that the unopened pack of win 3.11 disks Ive got contained the DOS disks too.

Graham

Quote from: gpl on December 20, 2007, 10:37:52 AM
... or at least assumed that the unopened pack of win 3.11 disks Ive got contained the DOS disks too.


That set just may. I can't remember just how they used to package it.


Unopened, eh?
Hang on to that. It's value might be on the way BACK up!
Collector's items and all that.


Well, seeign as choice is a built in command, why wouldn't my menu work?

it perfectly fine for me, I use dos editor when in dos mode, and Notepad when not.
I use paint pretty often to, so I put my most used programs into one batch file, and alogn with kq3
i can EXECUTE almost any program I would normally use, from my little menu.
I plan on elaborating it though.

maybe like this:
Code: [Select]@echo off
:Begin
cls

echo 1. Editors
echo 2. Imaging
echo 3. Games

choice.com /c:123 (1, 2, or 3)%1
if errorlevel == 3 then goto Games
if errorlevel == 2 then goto Imaging
if errorlevel == 1 then goto Editors
cls
goto end

:Games
echo 1. King's Quest III
echo 2. Age of Empires

choice.com /c:12 (1, or 2)%2
if errorlevel == 2 then start [dir[path]] aoe.exe
if errorlevel == 1 then start c:\sierra\kq3
goto end

:Imaging
echo 1. Paint
echo 2. example

choice.com /c:12 (1, or 2)%3
if errorlevel == 2 then start example
if errorlevel == 1 then start mspaint
goto end

:Editors
echo 1. Notepad
echo 2. MS-DOS Editor

choice.com /c:12 (1, or 2)%4
if errorlevel == 2 then edit
if errorlevel == 1 then start notepad

:end

That works if you have more files. . this introduces Categories don't forget to go %1, %2, %3, etc. .at end of Choice commands.Another way to do a menu in batch is described here:

http://www.dostips.com/DtTipsMenu.php
http://www.dostips.com/DtTipsMenu2.php

From the extensibility point of view a cool thing. You can add new menu items and code ANYWHERE in the batch, the smart menu loop will automatically discover and display them.

Like that?


Discussion

No Comment Found