2

I am trying to have a menu with some names. Each name will be represented with a number. If I enter the number. It will open youtube or google.

I can do this with the (goto) option but in this case I am trying to replace the word droploc with youtube or google for example. Is it possible?

@echo off
@echo menu
@echo enter 1 for google
@echo enter 2 for youtube
    set google=1                           
    set youtube=2                          

    REM Example 1                          

    if "%1%" == "1" (                      
      set dropLoc=1                        
    )                                      

    echo %dropLoc%                         
    start "link" "https://dropLoc   

2 Answers 2

2

You are not prompting for a value to process. Try the following, it should get you started.

@echo off

:Menu
@echo menu
@echo enter 1 for google
@echo enter 2 for youtube

REM Prompt user to enter a value.
SET /P Selection=Enter selection:

SET dropLoc=null

REM Set the dropLoc based on the user selection.
IF "%Selection%" == "1" SET dropLoc=www.google.com
IF "%Selection%" == "2" SET dropLoc=www.youtube.com

REM If no valid selection, send the user back to the menu.
IF "%dropLoc%" == "null" (
    ECHO Enter a valid selection.
    GOTO Menu
)

echo %dropLoc%                         
start "link" "https://%dropLoc%
Sign up to request clarification or add additional context in comments.

2 Comments

I am very new with batch file. I have spent about 20 hours with this. You made it in a moment. Thank you.
@kboga - Glad to help. We all have to start somewhere. Keep at it.
0

Try Set droploc="google" Inside your if clause

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.