选择计划

时间:2013-02-15 16:23:19

标签: batch-file choice

我正在尝试创建一个在用户做出选择后发送消息的程序,但是在做出选择之后它就会关闭cmd。任何帮助?继承人计划。

    @echo off
    title Get A Life
    cd C:
    :menu
    cls
    echo I take no responsibility for your actions. Beyond this point it is you that   has the power to kill yourself. If you press ‘x’ then your PC will be formatted. Do not cry if you loose your data or anything.
    pause
    echo Pick your option:
    echo 1. Die slowly
    echo 2. Instant Death
    echo 3. Stay Away From This One
    echo 4. Die this way (For Wimps!)
    echo 5. Easy way out
    set input=nothing
    set /p input=Choice:
    if %input%=1
    then msg * Your computer will now sutdown
    else GOTO END
    if %input%=2
    then msg * Your hard drive will now be formatted
    else GOTO END
    if %input%=3
    then msg * FINE! JUST PICK THE MIDDLE ONE!
    else GOTO end
    if %input%=4 
    then msg * Can you guess what happens next?
    else GOTO END
    if %input%=5
    then START %documents%/%Personal Projects%/Cool trick.bat
    :END

2 个答案:

答案 0 :(得分:0)

尝试一下:

@echo off
title Get A Life
cd C:
:menu
cls
echo I take no responsibility for your actions. Beyond this point it is you that   has the power to kill yourself. If you press ‘x’ then your PC will be formatted. Do not cry if you loose your data or anything.
pause
echo Pick your option:
echo 1. Die slowly
echo 2. Instant Death
echo 3. Stay Away From This One
echo 4. Die this way (For Wimps!)
echo 5. Easy way out
set input=nothing
set /p input=Choice:

if %input%==1 (
    msg * Your computer will now sutdown
) else if %input%==2 (
    msg * Your hard drive will now be formatted
) else if %input%==3 (
    msg * FINE! JUST PICK THE MIDDLE ONE!
) else if %input%==4 (
    msg * Can you guess what happens next?
) else if %input%==5 (
    START %documents%/%Personal Projects%/Cool trick.bat
)
:END

答案 1 :(得分:0)

好吧,我不确定它是什么语言,但这里是Windows批处理:

@echo off
title Get A Life
cd C:
:menu
cls
echo I take no responsibility for your actions. Beyond this point it is you that   has the power to kill yourself. If you press ‘x’ then your PC will be formatted. Do not cry if you loose your data or anything.
pause
echo Pick your option:
echo 1. Die slowly
echo 2. Instant Death
echo 3. Stay Away From This One
echo 4. Die this way (For Wimps!)
echo 5. Easy way out
set input=nothing
set /p input="Choice: "

for %%I in (1 2 3 4 5) do if "%choice%"=="%%I" goto run%%I
goto :EOF

:run1
echo * Your computer will now sutdown
goto :EOF

:run2
echo * Your hard drive will now be formatted
goto :EOF

:run3
echo * FINE! JUST PICK THE MIDDLE ONE!
goto :EOF

:run4
echo * Can you guess what happens next?
goto :EOF

:run5
START %documents%/%Personal Projects%/Cool trick.bat