我一直都在做,但都使出在命令行中輸入如下:如何製作一個bat文件,詢問用戶他們想要修復的驅動器?
CHKDSK C: /f
我試圖查找如何做到這一點,但即時通訊上的bat文件編程並不大,更何況我只是一個小程序員學習java atm ... 我想知道如何做到這一點,所以知道如何計算它。因爲這會對我有長遠的幫助,並在短期內對我有所幫助。
將不勝感激。 :)
我一直都在做,但都使出在命令行中輸入如下:如何製作一個bat文件,詢問用戶他們想要修復的驅動器?
CHKDSK C: /f
我試圖查找如何做到這一點,但即時通訊上的bat文件編程並不大,更何況我只是一個小程序員學習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
這個腳本更容易編寫和理解,但不應該被使用:
@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
可能的重複[在Windows cmd中,如何提示用戶輸入並在另一個命令中使用結果?](http://stackoverflow.com/questions/1223721/in-windows-cmd-how-我也可以看看這個==> [我怎樣才能得到一個CHKDSK的結果,運行結果在另一個com中] –
在開機?](http://stackoverflow.com/questions/38504689/how-can-i-get-the-results-of-a-chkdsk-that-run-on-boot) – Hackoo