批量换行问题

时间:2014-01-19 22:24:16

标签: windows shell batch-file cmd

我有两个文件,shell.batkey.batshell.bat调用key.bat以及名为etc的目录中的其他一些文件。 key.bat要求用户提供ESSID,在etc中找到相应的文件,并在type找到其内容,这是所请求的ESSID的密钥。之后,再次调用shell.bat,并在调用文件server:wifi$的内容后显示shell提示符key.bat。关于如何解决这个问题的任何想法?

shell.bathttp://www.mediafire.com/view/skrs8e728023f6f/shell.bat

@echo off
set /p cmd=server:wifi$ 
if exist programs\%cmd%.bat goto cmd
goto fail

:cmd
call programs\%cmd%.bat
call shell.bat

:fail
echo Command "%cmd%" not found.
call shell.bat

key.bathttp://www.mediafire.com/view/rm1v6czi3f4844c/key.bat

@echo off
set /p essid=ESSID: 
if exist etc\%essid%.txt goto key
goto fail

:fail
echo Key does not exist.
echo Add key with "mkkey".
goto :eof

:key
type etc\%essid%.txt

1 个答案:

答案 0 :(得分:1)

尝试此修改,然后告诉我们是否仍有问题,并进一步描述。

shell.bat

@echo off
set "cmd="
set /p cmd=server:wifi$ 
if exist "programs\%cmd%.bat" goto cmd
goto fail

:cmd
call "programs\%cmd%.bat"
%0

:fail
echo Command "%cmd%" not found.
%0

Key.bat

@echo off
set "essid="
set /p essid=ESSID: 
if exist "etc\%essid%.txt" goto key
goto fail

:fail
echo Key does not exist.
echo Add key with "mkkey".
goto :eof

:key
type "etc\%essid%.txt"