我今天早些时候在这里问了一个问题,得到了修复,但现在我有另一个问题..我的批处理文件应该采取用户输入然后将该目录中文件的所有名称保存到用户指定的名称文本文件中。它也可以选择允许你包含或不包含子目录和隐藏/系统文件。我的问题是正确的,当用户决定包括隐藏/系统文件和子目录,它才能正常运行,否则,它崩溃。这里是代码:批处理文件只适用于当用户输入是这两个问题..否则它崩溃
@echo off
:start
set /P DIRECTORY=Type Directory to Search:
if not exist %DIRECTORY% goto :firstlogin
set /P FILENAME=Type the name for your output file:
:choice
set /P c=Include Sub-Directories?[y/n]?
if /I "%c%" EQU "Y" goto :somewhere
if /I "%c%" EQU "y" goto :somewhere
if /I "%c%" EQU "Yes" goto :somewhere
if /I "%c%" EQU "yes" goto :somewhere
if /I "%c%" EQU "YES" goto :somewhere
if /I "%c%" EQU "N" goto :somewhere_else
if /I "%c%" EQU "n" goto :somewhere_else
if /I "%c%" EQU "No" goto :somewhere_else
if /I "%c%" EQU "no" goto :somewhere_else
if /I "%c%" EQU "NO" goto :somewhere_else
goto :choice
:somewhere
set /P d=Include Hidden and System Files?[y/n]?
if /I "%d%" EQU "Y" goto :d1
if /I "%d%" EQU "y" goto :d1
if /I "%d%" EQU "Yes" goto :d1
if /I "%d% EQU "yes" goto :d1
if /I "%d%" EQU "YES" goto :d1
if /I "%d%" EQU "N" goto :d2
if /I "%d%" EQU "n" goto :d2
if /I "%d%" EQU "No" goto :d2
if /I "%d%" EQU "no" goto :d2
if /I "%d%" EQU "NO" goto :d2
goto :somewhere
:d1
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait...
Pause
dir /a /s /b /o "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit
:d2
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait...
Pause
dir /s /b /o "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit
:somewhere_else
set /P e=Include Hidden and System Files?[y/n]?
if /I "%e%" EQU "Y" goto :e1
if /I "%e%" EQU "y" goto :e1
if /I "%e%" EQU "Yes" goto :e1
if /I "%e%" EQU "yes" goto :e1
if /I "%e%" EQU "YES" goto :e1
if /I "%e%" EQU "N" goto :e2
if /I "%e%" EQU "n" goto :e2
if /I "%e%" EQU "No" goto :e2
if /I "%e%" EQU "no" goto :e2
if /I "%e%" EQU "NO" goto :e2
goto :somewhere_else
e1:
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait...
Pause
dir /a /b /o "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit
e2:
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait...
Pause
dir /b /o "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit
:firstlogin
echo Directory does not exist!
Pause
goto :start
:done
SET stg=
SET /P stg=Start again?[y/n]?
cls
IF %stg% == Y goto :START
IF %stg% == y goto :START
IF %stg% == yes goto :START
IF %stg% == Yes goto :START
IF %stg% == YES goto :START
'否则,它崩溃..'怎么样? – 2010-02-26 05:30:20
批处理崩溃时该做什么?你是否用'REM'''@echo off'命令来追踪流程? – akf 2010-02-26 05:32:31
它只是关闭而没有做任何事情,也没有我没有遵循流程;我现在就试试。编辑:后面的流程没有帮助,它似乎是完美运行,一切都去了它应该在哪里,但然后坠毁.. – Tofugamer 2010-02-26 05:34:13