在 CMD 批处理文件中使用用户输入打开 URL

Opening URLs with user input in CMD Batch File

我是静态 Web 开发人员。 & 我不太了解 CMD 和批处理文件。 但是我需要制作一个批处理文件,它 this:It 首先提示用户输入一个特定的词,并且有一些 link 具有 URL 和某种名称。然后,如果用户的输入与 link 的名称之一相匹配,URL 将在浏览器(默认浏览器)中打开。我认为 HTML+JS:

是这样的
<!doctype html>
<html>
<head>
<script>
    function input(){
        var Whosebug = "http://whosebug.com";
        var val = document.getElementById("input").value;
        if (val = Whosebug){
            window.open(Whosebug);
        }
    }
</script>
</head>
<body>
<input type="text" id="input" onKeyUp="input()"/>
</body>
</html>

但应该有更多选项,我认为应该使用 START 命令来完成。 任何帮助是 appreciated.THX

您要找的是一个简单的菜单,

:: turn off "verbose" command writeback.
@echo off

:: write a simple list of options to console,
:main
echo Options;
echo 1 : Whosebug
echo 2 : Google
echo 3 : Youtube
echo 4 : This question

:: Prompt for input,
set /p "strMenu=Enter desired URL number:"

:: Compare input through if commands,
:: `if not defined strMenu goto :menu` can be used here if prefered.
if "%strMenu%" equ "1" start "" "https://www.whosebug.com"
if "%strMenu%" equ "2" start "" "https://www.Google.com"
if "%strMenu%" equ "3" start "" "https://www.youtube.com"
if "%strMenu%" equ "4" start "" ""

exit

请注意,开始命令将使用默认分配的浏览器,但这可以用类似的东西进行设置;

start "" "chrome" "URL"

数字用于懒惰,因为在按回车键之前必须输入超过 1 个字符。