cmd要求用户使用不同的操作进行多次输入

时间:2014-12-10 05:07:53

标签: windows batch-file cmd

我只是尝试制作mini-dos,为每个输出做不同的动作。这就是我想要的: 如果用户输入?然后它会输入:

"del for delete.(you will get to type the file name later.)"
"edit for text editor."
"remoteshutdown for remote shutdown(Real) computer."
"note for mickywachi's note"

它工作得很完美但是如果我输入del,编辑,遥控器,音符和其他东西它会做同样的事情! 我想要del做什么:

Type in file you want to delete!

(input for file name)

然后它将删除该文件并再次请求输入。 我想要编辑的是打开一个额外的程序。与remoteshutdown和note相同。 当用户键入错误的命令时我想要它做什么:

(username they logged on), you typed in the wrong command! type ? for help.

它会再次要求输入。 有人可以帮忙吗?这是代码(跳过大文本和登录并转到标签输入。这就是问题所在。)

@echo off

title miOS

color 12

echo "-------------------------"
echo "           _  ___  ____  "
echo " _ __ ___ (_)/ _ \/ ___| " 
echo "| '_ ` _ \| | | | \___ \ "
echo "| | | | | | | |_| |___) |"
echo "|_| |_| |_|_|\___/|____/ "
echo "-------------------------"

echo Copyright(C)mickywachi. All rights Reserved.

pause

cls

color f0
echo Starting miOS....
set current=%CD%
echo Please Login.

:login

color f0
set /p username=Username: 

if %username%==Administrator goto passlogin

if %username%==mickywachi goto passlogin else {
    color f4
    echo Wrong User!
    pause
    goto :login
}

:passlogin

color f0
set /p password=Password: 
if %username% == Administrator if %password%==admin goto logon

if %username% == mickywachi if %password%==micky1594 goto logon else {
    color f4
    echo Wrong Password!
    pause
    goto :passlogin
}

:logon

echo Welcome to miOS!
echo Type ? for help.

:input

set /p input=%current%: 

if %input%==? {
    echo "del for delete.(you will get to type the file name later.)"
    echo "edit for text editor."
    echo "remoteshutdown for remote shutdown(Real) computer."
    echo "note for mickywachi's note"

    set input=/
    goto input
}

if %input%==del {
    echo Type in file name you want to delete!

    set /p delwhat=: 
    del %current%\%delwhat%.mifile
    set input=/

    goto input
}

if %input%==remoteshutdown start REMOTESHUTDOWN.bat

if %input%==note start mickywachiNote.bat else {
    echo %username%, You typed in wrong command! type ? for help.
    set input=/

    goto input
}

有人对这个问题有所了解吗?

1 个答案:

答案 0 :(得分:0)

您的条件操作语句必须用圆括号( )括起来{ }

这里没有选择。