简体   繁体   English

批处理文件不会跳转到 Label

[英]Batch File Won't Jump to Label

I have an unfinished batch file that wont jump to the:TBS label.我有一个未完成的批处理文件,它不会跳转到:TBS label。 It will always go to the:BSO label no matter what you put in for the first question.无论您在第一个问题中输入什么内容,它都将始终是 go 到:BSO label。 "A" should go to:BSO and "B" should go to:TBS. “A”应为 go 至:BSO,“B”应为 go 至:TBS。 I don't know how to fix this.我不知道如何解决这个问题。 I have tried everything I can think of.我已经尝试了我能想到的一切。 Any help appreciated.任何帮助表示赞赏。

@echo off
echo ------------------------------------------Computer Optimization and Fixer 1.1-------------------------------------------
echo.
echo Welcome to Computer Optimization and Fixer 1.1 by Anston
echo.
echo Computer Optimization and Fixer 1.1 will do a basic optimization and fix issues on your computer. For example...
echo It can run sfc, chkdsk, Defrag or Optimize, Disk Cleanup, DISM, troubleshooters, and more.
echo.
set /p A="Would you like to do a basic optimization(A) or fix a certain issue(B)?"
IF %A% EQU A GOTO:BSO
IF %A% EQU B GOTO:TBS
:BSO
echo.
echo Running basic optimization...
pause
start "dfrgui.exe" /wait "C:\Windows\System32\dfrgui.exe"
sfc /scannow
chkdsk /r
start diskclean
GOTO:END
:TBS
echo.
set /p ch="What problem do you have?(Power[A], Internet[B], Performance[C], Files[D], Windows Apps[E], Windows Update[F], Devices[G], Audio[H], Search[I], or Printer[J])
IF %ch% EQU A GOTO:PWR
IF %ch% EQU B GOTO:INT
IF %ch% EQU C GOTO:PRF
IF %ch% EQU D GOTO:FLS
IF %ch% EQU E GOTO:WNA
IF %ch% EQU F GOTO:WNU
IF %ch% EQU G GOTO:DEV
IF %ch% EQU H GOTO:AUD
IF %ch% EQU I GOTO:SCH
IF %ch% EQU J GOTO:PRN
:PWR
echo.
echo Running Troubleshooter...
msdt.exe /id PowerDiagnostic
pause
GOTO:END
:END
cls
echo ------------------------------------------Computer Optimization and Fixer 1.1-------------------------------------------
echo.
echo Thank you for using Computer Optimization and Fixer 1.1
pause

There is a command available since Windows Vista and on Windows Server versions since Windows Server 2003 for choice menus: CHOICE自 Windows Vista 和自 Windows Server 2003 以来的 Windows 服务器版本以来,有一个命令可用,用于选择菜单: CHOICE

@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "ToolVersion=1.1"
cls
echo --------------------- Computer Optimization and Fixer %ToolVersion% ---------------------
echo/
echo Welcome to Computer Optimization and Fixer %ToolVersion% by Anston
echo/
echo Computer Optimization and Fixer %ToolVersion% will do a basic optimization
echo and fix issues on your computer. For example, it can run Check Disk
echo Utility, Disk Space Cleanup Manager for Windows, Disk System Integrity
echo Check and Repair, Disk Defragmenter, troubleshooters, and more.
echo/
echo What do you want to do?
echo/
echo    A ... do a basic optimization
echo    B ... fix a certain issue
echo    E ... do nothing and exit
echo/
%SystemRoot%\System32\choice.exe /C ABE /N /M "Your choice:"
if errorlevel 3 goto :EOF
if errorlevel 2 goto TBS

echo/
echo Running basic optimization...
%SystemRoot%\System32\chkdsk.exe /r
%SystemRoot%\System32\cleanmgr.exe
%SystemRoot%\System32\sfc.exe /scannow
%SystemRoot%\System32\dfrgui.exe
goto END

:TBS
echo/
echo What problem do you have?
echo/
echo    A ... Power
echo    B ... Internet
echo    C ... Performance
echo    D ... Files
echo    E ... Windows Apps
echo    F ... Windows Update
echo    G ... Devices
echo    H ... Audio
echo    I ... Search
echo    J ... Printer
echo    N ... None of above
echo/
%SystemRoot%\System32\choice.exe /C ABCDEFGHIJN /N /M "Your choice:"
echo/
goto Option%Errorlevel%

:Option1
echo Running diagnostics troubleshooting wizard ...
%SystemRoot%\System32\msdt.exe /id PowerDiagnostic
goto FINISH

:Option2
echo Check for Internet problems ...
goto FINISH

:Option3
echo Check for performance problems ...
goto FINISH

:Option4
echo Check for file problems ...
goto FINISH

:Option5
echo Check for problem with Windows Apps ...
goto FINISH

:Option6
echo Check for Windows update problems ...
goto FINISH

:Option7
echo Check for device problems ...
goto FINISH

:Option8
echo Check for audio problems ...
goto FINISH

:Option9
echo Check for search problems ...
goto FINISH

:Option10
echo Check for printer problems ...
goto FINISH

:Option11
echo Sorry, this tool cannot help you.

:FINISH
echo/
pause

:END
cls
echo --------------------- Computer Optimization and Fixer %ToolVersion% ---------------------
echo/
echo Thank you for using Computer Optimization and Fixer %ToolVersion%
echo/
endlocal
pause

For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.要了解使用的命令及其工作原理,请打开命令提示符window,在其中执行以下命令,并仔细阅读每个命令显示的所有帮助页面。

  • chkdsk /?
  • choice /?
  • cleanmgr /?
  • cls /?
  • defrag /? ... console version of dfrgui.exe ... dfrgui.exe的控制台版本
  • dism /?
  • echo /?
  • endlocal /?
  • goto /?
  • if /?
  • pause /?
  • set /?
  • setlocal /?
  • sfc /?

Please read also:另请阅读:

Note: The execution of disk defragmenter is not necessary on SSD hard disks.注意: SSD 硬盘上不需要执行磁盘碎片整理程序。 So the batch file should check of which type each local drive is before running disk defragmenter on a drive.因此,批处理文件应在驱动器上运行磁盘碎片整理程序之前检查每个本地驱动器的类型。

PS: The names of the executables used for basic optimizations can be read by clicking with secondary (usually right) mouse button on an executable like sfc.exe , clicking in opened context menu with primary (usually left) mouse button on last menu item Properties , selecting the tab Details and looking on item File description . PS:用于基本优化的可执行文件的名称可以通过在像sfc.exe这样的可执行文件上单击辅助(通常是右键)鼠标按钮来读取,在最后一个菜单项属性上使用主(通常是左)鼠标按钮单击打开的上下文菜单,选择选项卡详细信息并查看项目文件描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM