Windows Legacy OS forum

General discussion

Can it be done?

by David_MKD / May 1, 2011 8:11 PM PDT

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
You are posting a reply to: Can it be done?
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: 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.
Collapse -
What kind of files are a, b and c?
by Kees_B Forum moderator / May 1, 2011 8:23 PM PDT
In reply to: Can it be done?

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
by David_MKD / May 1, 2011 8:30 PM PDT

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

Collapse -
(NT) File a is an exe file?
by Kees_B Forum moderator / May 1, 2011 8:35 PM PDT
In reply to: Cant Understand
Collapse -
yeah
by David_MKD / May 1, 2011 9:05 PM PDT
In reply to: File a is an exe file?

A game GTA SA

Collapse -
Re: game
by Kees_B Forum moderator / May 1, 2011 9:21 PM PDT
In reply to: yeah

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 ...
by Edward ODaniel / May 5, 2011 4:32 AM PDT
In reply to: Can it be done?

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
:ONE
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
:Paint
start MSPAINT.EXE
GOTO LOOP
:Prompt
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
by MarkFlax Forum moderator / May 5, 2011 4:50 AM PDT
In reply to: Sure can ...

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

Popular Forums
icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

CNET FORUMS TOP DISCUSSION

Help, my PC with Windows 10 won't shut down properly

Since upgrading to Windows 10 my computer won't shut down properly. I use the menu button shutdown and the screen goes blank, but the system does not fully shut down. The only way to get it to shut down is to hold the physical power button down till it shuts down. Any suggestions?