Pages

Subscribe:

Friday, August 5, 2011

How to run automatic chkdsk using a batch file

If you have a lot of partitions and you want to run checkdisk on all of them, instead of doing it individually for each drive, you can use this batch file.
Copy and paste the following code into a notepad and save the file with a .bat extension.
Eg. “checkdisk.bat”
1. When saving the file, use the quotation marks in the file name so notepad doesn’t assign the default .txt extension.
2. Run this batch file(double click it to run) from any drive other than your windows drive.
3. Edit(right click the batch file > edit) the file depending on how many partitions you have.
4. Your windows drive should be the very first.
5. In the below code my windows drive is C: so I started with ECHO Y| chkdsk C: /F
6. Got it? good. If not good luck. icon razz How to run automatic chkdsk using a batch file
Code:

@ECHO OFFTITLE CHECK DISKCOLOR 9FECHO ================ECHO Checking Drive CECHO ================ECHO.ECHO.ECHO Y| chkdsk C: /FECHO.ECHO.ECHO ================ECHO Checking Drive DECHO ================ECHO.ECHO.ECHO N > check.TXTECHO Y >> check.TXTTYPE check.TXT| chkdsk D: /FECHO.ECHO.ECHO ================ECHO Checking Drive EECHO ================ECHO.ECHO.TYPE check.TXT| chkdsk E: /FDEL check.TXTECHO.ECHO.PAUSEPAUSE
Eg. If you have another drive F then in your batch file,
after this line TYPE check.TXT| chkdsk E: /F and
before this line DEL check.TXT add the following code and so on for as many drives as you have.
Code:
ECHO.ECHO.ECHO ================ECHO Checking Drive FECHO ================ECHO.ECHO.TYPE check.TXT| chkdsk F: /F
Restart your comp so checkdisk can check the drives that were in use. If you want you can also copy and paste the below given code to the end of your batch file to restart your comp automatically.
Code:
clsshutdown -r -f -t 180 -c "The computer will restart in 3 minutes when the timer counts backwards to zero. Please exit all running programs. To abort this shutdown Go to Start > Run > type cmd > Hit enter > type shutdown -a > hit enter."
1. In shutdown -r -f -t 180 180 means seconds. So it means your comp will restart in 3 minutes. You can change 180 to 0 for an instant restart.
2. Recommend running checkdisk before and after a manual defrag.

 
Image by FlamingText.com

0 comments:

Post a Comment

Dear Visitor If you like my post please post your Comments

Search This Blog