bugfixer.bat批处理文件询问最终用户他们想要运行哪个选项

时间:2015-05-03 20:37:42

标签: batch-file command-line batch-processing

有趣的东西!!

经理刚买了一个实用工具。它做了一切。它甚至还具有命令行功能。如果您运行BugFixer / a,应用程序将自动扫描整个驱动器以获取cooties。如果您运行Bugfixer / b,它将扫描Windows \ system 32目录中的所有文件,如果您运行Bugfixer / c,程序将扫描并修复您的注册表。需要编写一个批处理文件,允许用户通过命令行避免那个讨厌的GUI并有效地运行Bug修复程序,询问他们想要初始化哪个选项。

:TOP 
ECHO WHICH BUG FIXER DO YOU NEED TO RUN? A=ALL B=SOME c=REPAIR 
SET /P = %USERSPEC% 
IF "%1"=="A=ALL" GO TO :FIRST 
IF "%1"=="A=all" GO TO :FIRST 
:FIRST
CHKDSK C:
ECHO CHECKING ALL FILES ARE COMPLETE 
IF "%2"=="B=SOME" GO TO :NEXT
IF "%2"=="b=some" GO TO :NEXT 
:NEXT 
CHKDSK /F /R C:\WINDOWS/SYSTEM32 
ECHO CHECKING SOME FILES ARE COMPLETE 
IF "%3"=="REPAIR" GO TO :LAST 
IF "%3"=="repair" GO TO :LAST 
:LAST
CHKDSK /c 
ECHO REPAIR FILES ARE COMPLETED

就像我说有趣的东西。有人想帮忙吗?

1 个答案:

答案 0 :(得分:0)

下一个脚本逻辑可能会有所帮助:

@echo OFF >NUL
setlocal enableextensions
:TOP
echo(
set "USERSPEC="
set /P "USERSPEC=Which bug fixer do you need to run? A=all B=some C=repair? "
if /I "%USERSPEC%"=="A" goto :FIRST 
if /I "%USERSPEC%"=="B" goto :NEXT  
if /I "%USERSPEC%"=="C" goto :LAST
echo NO CHECK CHOOSEN, BATCH ENDS
goto :ENDSCRIPT

:FIRST
chkdsk C:
echo CHECKING ALL FILES ARE COMPLETE 
goto :TOP

:NEXT 
chkdsk /F /R C:\WINDOWS/SYSTEM32 
echo CHECKING SOME FILES ARE COMPLETE 
goto :TOP

:LAST
chkdsk /c 
echo REPAIR FILES ARE COMPLETED
goto :TOP

:ENDSCRIPT
endlocal
goto :eof

然而,运行它:

==>30019117.bat

Which bug fixer do you need to run? A=all B=some C=repair? a
Access Denied as you do not have sufficient privileges.
You have to invoke this utility running in elevated mode.
CHECKING ALL FILES ARE COMPLETE

Which bug fixer do you need to run? A=all B=some C=repair?
NO CHECK CHOOSEN, BATCH ENDS

==>

资源(建议阅读):