批量文件不会跳转到标签

问题描述 投票:0回答:1

我有一个未完成的批处理文件,它不会跳到:TBS标签。无论你在第一个问题中输入什么,它总是会跳到 :BSO 标签。"A "应该转到:BSO,"B "应该转到:TBS。我不知道如何解决这个问题。我已经尝试了所有我能想到的方法。感谢任何帮助。

@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
windows batch-file command-line
1个回答
0
投票

从Windows Vista和Windows Server 2003开始的Windows Server版本中,有一个命令可以用于选择菜单。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

为了了解所使用的命令和它们如何工作,请打开一个 命令提示符 窗口,在那里执行以下命令,并仔细阅读每个命令的所有帮助页面。

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

还请阅读。

注意事项:在SSD硬盘上不需要执行磁盘碎片整理程序。 在SSD硬盘上不需要执行磁盘碎片整理程序。所以,在硬盘上运行磁盘碎片整理程序之前,批处理文件应该检查每个本地硬盘的类型。

PS: 基本优化所使用的可执行文件的名称可以通过用鼠标二级键(通常是右键)点击一个可执行文件来读取,如 sfc.exe在打开的上下文菜单中,用鼠标主键(通常是左键)点击最后一个菜单项。属性,选择标签 详细内容 和看项目 文件说明.

© www.soinside.com 2019 - 2024. All rights reserved.