如何批量回到某一点

时间:2014-10-07 10:17:17

标签: batch-file

现在我知道如何创建我所谓的标签

例如:startgame

我知道goto :startgame或者在某些情况下只是goto startgame会带你回来

当我在做if %selector% == r goto :Start_1时 它只是简单地关闭批处理文件,我已尝试使用大写,没有和没有:

现在不要粗鲁,叫我无知我知道基本批次

这是我的开始代码

:Start_1
echo **************************************************
echo ************App selector by michaelukz************
echo **************************************************
echo **************************************************
echo To select an app press any button.
pause

这是我想要开始工作的代码

:Selected
echo You have selected your file.
echo If you wish to choose another file press R.
echo If you wish to close a program / file press C.
echo If you wish to close press any button.
SET /P"selected=Input letter here:      "
if %selector% == r goto :Start_1
if %selector% == R goto :Start_1
if %selector% == c start taskmgr.exe
if %selector% == C start taskmgr.exe
if not timeout /T 3
echo Going to close menu
goto Closemenu
除了goto start_1之外,

所有其他工作。

请帮助但不要无知 - 我看到其他人在这里表现得很吵。

2 个答案:

答案 0 :(得分:3)

一些事情......

  1. 您所谓的标签通常称为标签。
  2. 在您的代码中,您要在此行selected中设置名为SET /P"selected=Input letter here: "的变量,但在IF语句中,您要与名为selector的变量进行比较。< / LI>
  3. if not timeout /T 3行不起作用。正如@Magoo在对该问题的评论中指出的那样,if的语法需要比较运算符if [not] something compare-op something_else dothis

答案 1 :(得分:1)

查看CHOICE命令,selector

中的拼写错误名称SET /P var {
@echo off
:Start_1
echo **************************************************
echo ************App selector by michaelukz************
echo **************************************************
echo **************************************************
echo To select an app press any button.

:Selected
echo You have selected your file.
echo If you wish to choose another file press R.
echo If you wish to close a program / file press C.
echo If you wish to close press Q.
choice /C RCQ /N /M "Choose wisely [R,C,Q]" /D Q /T 30
goto action%errorlevel%

:action1
echo option R
goto start_1
goto selected

:action2
echo option C
start taskmgr.exe
goto selected

:action3
echo option Q
goto closemenu


goto Closemenu