General discussion

Can it be done?

Can any one please post here command line such that- i have 3 files(a,b,c). I want to give an option in file a (y/n). When the user press y key, then file b should open and when n key is pressed file c opens.

Discussion is locked
Follow
Reply to: Can it be done?
PLEASE NOTE: Do not post advertisements, offensive materials, profanity, or personal attacks. Please remember to be considerate of other members. If you are new to the CNET Forums, please read our CNET Forums FAQ. All submitted content is subject to our Terms of Use.
Reporting: Can it be done?
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Comments
- Collapse -
What kind of files are a, b and c?

To do it in html, for example, you would need some Javascript. But in that case, two links to click on would be easier.
In MS Word you would need a macro.

My guess is that you mean either a batch file or a cmd file or a vbscript file or a powershell file. But you forgot to tell.


Kees

- Collapse -
Cant Understand

Well the files are .exe. I think I can do that with CMD ?

- Collapse -
(NT) File a is an exe file?
- Collapse -
yeah

A game GTA SA

- Collapse -
Re: game

I'm afraid you can't change the game, unless you have the source of the program. So unless you happen to work with Rockstar, the author of the game, you're out of luck.

Kees

- Collapse -
Sure can ...

we used to do it all the time in DOS and in Windows 3.X and earlier.

Just think of EXACTLY what you want to do then write the batch file to perform it. the bold text below is an example using the CHOICE command (available in DOS, Win 9X, and again in Vista and Win 7 but not in Win 2K or XP):

MENU.BAT

@ECHO OFF
CLS
echo.
ECHO.
ECHO.
echo.
ECHO ***************************************************************
ECHO.
ECHO This menu will allow you to open a program of your choice.
ECHO.
ECHO Choose from the following list
echo.
ECHO 1. Notepad a. Command Prompt
ECHO 2. Wordpad X. Exit
ECHO 3. MS Paint
echo. 4. Task Manager
ECHO.
ECHO *****************************************************************
ECHO.
echo.
CHOICE /c:1234aX
IF ERRORLEVEL==6 GOTO END
IF ERRORLEVEL==5 GOTO A
IF ERRORLEVEL==4 GOTO FOUR
IF ERRORLEVEL==3 GOTO THREE
IF ERRORLEVEL==2 GOTO TWO
IF ERRORLEVEL==1 GOTO ONE

GOTO END

:A
start CMD
GOTO LOOP
:FOUR
start TASKMGR.EXE
GOTO LOOP
:THREE
start MSPAINT.EXE
GOTO LOOP
:TWO
start WORDPAD.EXE
GOTO LOOP
ShockedNE
start NOTEPAD.EXE
GOTO LOOP
:LOOP
MENU.BAT
:END


To use in Windows XP which doesn't have the CHPOICE command you need to modify it with the SET command like the following example:

SETMENU.BAT

@ECHO off
cls
:start
ECHO.
ECHO 1. Notepad
ECHO 2. Paint
ECHO 3. Command Prompt
ECHO 4. Exit
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto Notepad
if '%choice%'=='2' goto Paint
if '%choice%'=='3' goto Prompt
if '%choice%'=='4' goto End
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:Notepad
start notepad.exe
GOTO LOOP
Sillyaint
start MSPAINT.EXE
GOTO LOOP
Sillyrompt
start cmd.exe
GOTO LOOP
:LOOP
SETMENU.BAT
:End


Modify as desired substituting the names of your desired executable files and you will have the menu you seem to want. Have Fun!

- Collapse -
Quick query

Edward, a quick query if you don't mind.

It's a long time since I created a menu.bat like that and my memory has faded.

You mentioned "Choice" in CHOICE /c:1234aX

But then in the Windows XP sentence you mention "CHPOICE".

Spelling error, or is CHPOICE a DOS command?

Mark

CNET Forums