簡體   English   中英

批處理文件不會跳轉到 Label

[英]Batch File Won't Jump to Label

我有一個未完成的批處理文件,它不會跳轉到:TBS label。 無論您在第一個問題中輸入什么內容,它都將始終是 go 到:BSO label。 “A”應為 go 至:BSO,“B”應為 go 至: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 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

要了解使用的命令及其工作原理,請打開命令提示符window,在其中執行以下命令,並仔細閱讀每個命令顯示的所有幫助頁面。

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

另請閱讀:

注意: SSD 硬盤上不需要執行磁盤碎片整理程序。 因此,批處理文件應在驅動器上運行磁盤碎片整理程序之前檢查每個本地驅動器的類型。

PS:用於基本優化的可執行文件的名稱可以通過在像sfc.exe這樣的可執行文件上單擊輔助(通常是右鍵)鼠標按鈕來讀取,在最后一個菜單項屬性上使用主(通常是左)鼠標按鈕單擊打開的上下文菜單,選擇選項卡詳細信息並查看項目文件描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM