我正在尝试使用一些名称的菜单。 每个名字将用一个数字表示。 如果我input号码。 它会打开YouTube或谷歌。
我可以用(goto)选项来做到这一点,但在这种情况下,我试图用youtube或googlereplace单词droploc。 可能吗?
@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
你并没有提出要处理的价值。 尝试以下,它应该让你开始。
@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%
尝试设置droploc =“google”在你的if子句中