我一直试图这样做,但已经在命令行中输入了这个:
CHKDSK C: /f
我试着查看如何做到这一点,但我对bat文件编程并不是那么大,所以我只是一个学习java atm的小程序员... 我想知道如何做到这一点,所以知道如何计算它。因为它可以长期帮助我,并在短期内帮助我。
非常感谢。 :)
答案 0 :(得分:5)
此脚本会询问用户要修复哪个驱动器,然后在“修复”之前显示确认消息。驱动器:
@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
这个脚本更容易编写和理解,但不应该使用它:
@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