我一直试图这样做,但已经在命令行中输入:
CHKDSK C: /f
Run Code Online (Sandbox Code Playgroud)
我试图查找如何做到这一点,但我不是那么大的蝙蝠文件编程和更多,所以我只是一个小程序员学习java atm ...我想知道如何做到这一点,所以知道如何计算它.因为它可以长期帮助我,并在短期内帮助我.
非常感谢.:)
此脚本将询问用户修复哪个驱动器,然后在"修复"驱动器之前显示确认消息:
@echo off
:start
setlocal EnableDelayedExpansion
set letters= abcdefghijklmnopqrstuvwxyz
choice /n /c %letters% /m "Please enter the drive letter you would like to fix: "
set drv=!letters:~%errorlevel%,1!
echo Are you sure... to fix %drv%:\?
choice
if errorlevel 2 goto :start
chkdsk %drv%: /f
echo Complete!
pause
Run Code Online (Sandbox Code Playgroud)
此脚本更易于编写和理解,但不应使用它:
@echo off
:start
:: Clears the contents of the %drv% variable, if it's already set
set "drv="
:: Queries the user for input
set /p "drv=Please enter the drive letter you would like to fix: "
:: Check if input was blank
if "%drv%"=="" echo Don't leave this blank&goto :start
:: Check if input contained more then 1 letter (Doesn't account for numbers or special characters)
if not "%drv:~1,1%"=="" echo Please enter the drive letter&goto :start
echo Are you sure you want to fix %drv%:\?
choice
if errorlevel 2 goto :start
chkdsk %drv%: /f
echo Complete!
pause
Run Code Online (Sandbox Code Playgroud)