How to use chkdsk for Scandisk?
I would like to schedule a task to perform scandisk, does anyone have any suggestions on how to use chkdsk to do that? Thank everyone very much for any suggestions1 person got this answerI do too
August 14th, 2010 2:38am

You can run chkdsk in Windows, but you can't repair errors unless you schedule it to run on boot up. Then it will correct any errors it finds, then boot into Windows.SC Tom-There's no such thing as TMI when asking for tech support.
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2010 5:20am

Could you please give me any suggestions on how to set schedule to run chkdsk on boot up for every Sunday at 12 PM?I prefer using schedule task, which has option to startup window under hibernation mode.1) startup window under hibernation mode using schedule task2) restart window and run chkdsk3) after chkdsk, go back to sleep mode using hibernationDo you have any suggestions on how to code a batch file to perform above task? Thank everyone very much for any suggestions
August 14th, 2010 7:31am

Not sure how you would set that up in Scheduled Tasks, but here are some of the commands you'd need to;1. Restart Windows: ""%windir%\system32\shutdown -r -t 01"2. Hibernate Windows: "%windir%\system32\rundll32.exe PowrProf.dll, SetSuspendState"Both of these would be without the quote marks.This all brings up the question, what is happening to your PC that makes youfeel that it needs to be checked weekly? XP does a pretty decent job ofmanaging itself without user intervention.SC Tom-There's no such thing as TMI when asking for tech support.
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2010 5:34pm

Do you have any suggestions on how to code batch file to restart window for running chkdsk?Or can XP run chkdsk without restarting window? so I can hibernate window after chkdsk?Do anyone have any suggestions? Thank everyone very much for any suggestions
August 14th, 2010 6:13pm

On 8/14/2010 12:13 PM, oem7110 wrote:Do you have any suggestions on how to code batch file to restart window for running chkdsk?Or can XP run chkdsk without restarting window? so I can hibernate window after chkdsk?Do anyone have any suggestions?Did you let chkdsk run when you start the computer? If you let it run it should find and correct any disk errors and Windows should boot normally after the disk has been checked.You don't need to run chkdsk as a regular maintenance routine on your disks, chkdsk only needs to be run if you suspect disk or file system problems, you can run for years without running a chkdsk.Use two batch files to restart Windows and run chkdsk on the boot volume (the Windows drive, assumes C:) and hibernate the machine after chkdsk is done.The first batch file will shutdown the machine and run chkdsk. The file will also set the machine to run a second batch file and hibernate when the machine starts after chkdsk is done.Batch file #1, (Copy the stuff between the --- lines ---): -------------------chkdsk.bat-------------------------------echo y|chkdsk C: /Fschtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------ Batch file #2. This is the hib.bat batch file that is scheduled to run when the computer starts after the chkdsk is done. The Schtasks command in the first batch file schedules the file to run. You must place the file in the location called by the Schtasks command, in the above command the file is called from C:\, place in that location or if you want to save it in another location change the chkdsk.bat file accordingly.-------------------hib.bat------------------schtasks /delete /tn hib /fPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState------------------------------------------- John
Free Windows Admin Tool Kit Click here and download it now
August 15th, 2010 5:13pm

-------------------chkdsk.bat-------------------------------echo y|chkdsk C: /Fecho y|chkdsk D: /Fschtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------If I need to scandisk on C & D drives, is above coding correct? Thank everyone very much for any suggestions
August 15th, 2010 6:03pm

On 8/15/2010 12:03 PM, oem7110 wrote:-------------------chkdsk.bat------------------------------- echoy|chkdsk C: /Fecho y|chkdsk D: /Fschtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru "" shutdown-r -f -t 0------------------------------------------------------------ If Ineed to scandisk on C& D drives, is above coding correct?Assuming that D: is a data drive, no, not really. Chkdsk cannot run onthe Windows drive because Chkdsk needs an exclusive lock on the driveand it cannot get that exclusive lock while Windows is up and running,that is why the chkdsk must be scheduled to run at boot time.In the case of a data drive chkdsk can easily dismount the drive and getan exclusive lock on the drive, if you run the above "echo y|chkdsk D:/F" on a data volume it will dismount the volume (if files are open) andit will then proceed to immediately run chkdsk on the data drive whileWindows is up and running, there is usually no need to schedule chkdskto run at boot time on data disks.What you are wanting to do is becoming increasingly complex, you wouldneed to have the batch file open a file on the data drive then you wouldhave to pipe the output of the chkdsk command and use "IF" statements in the batch file to answer the questions asked by chkdsk.There are two ways to have Chkdsk run when the computer starts, Autochkwill run if you schedule it to run or by default it will run if thevolume's dirty bit is set. If the operating system detects problems itwill automatically set the dirty bit and the volume will be checked atthe next startup. The dirty bit can also be set manually with thefsutil command but it is best not to do this and to leave the setting ofthe dirty bit to the operating system. Once set the dirty bit cannot bechanged and while the boot time check can be skipped it cannot becanceled, on the other hand, a scheduled Chkdsk without the dirty bitcan be canceled at any time. Scheduled disk checks are recorded in theregistry at the BootExecute value at theHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager key.You can export the value for scheduled chkdsk then merge them at anytime to re-schedule them. To schedule a Chkdsk at the next reboot:On the Windows volume, assumes the volume is C:At the command prompt issue:chkntfs /d(this will reset the BootExecute value to its default and cancel any disk checks that may have been previously scheduled) then run the chkdsk commands:chkdsk c: /fChkdsk will return a message telling you that it cannot lock or dismountthe volume and ask you if you want to schedule a Chkdsk at the nextrestart, answer Yes.For dismountable data volume D:Open a file on the volume, or explore the volume with Explorer. Then atthe Command prompt issue:chkdsk d: /fChkdsk will inform you that the volume is being used by another processand it will ask you if you want to force a dismount on the volume,answer No. Chkdsk will then ask you if you want to schedule a Chkdsk atthe next restart, answer Yes.Now the drives are scheduled to run at the next restart. To do this ina semi-automated manner, after doing the above:Using Regedit export the[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager] key.This exported file will be fairly large, edit the saved file andremove/delete everything except the BootExecute value, the edited filewill look like this:==========================================================Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager]"BootExecute"=hex(7):61,00,75,00,74,00,6f,00,63,00,68,00,65,00,63,00,6b,00,20,....... with a long series of numbers.=====================================================(Leave a blank line at the end of the file.) You only want to save theBootExecute value, nothing else!Save the edited .reg file and when you want to schedule the Chkdsk mergeit to the registry, for example:regedit.exe /s "c:\BootChk.reg"If you want to cancel all scheduled Chkdsk at the command prompt issue"chkntfs /dYour first batch file could now be like so: Batch file #1, (Copy the stuff between the --- lines ---): -------------------chkdsk.bat-------------------------------regedit.exe /s "c:\BootChk.reg"schtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------- Without having to muck with registry files you can set the dirty bit on volume D: instead, the batch file could look like this: ------------------chkdsk.bat-------------------------------echo y|chkdsk C: /Ffsutil dirty set d:schtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------ John
Free Windows Admin Tool Kit Click here and download it now
August 15th, 2010 7:38pm

Just do following once a week (usually before going to bed) [save as btch file e.g. ckdkwk.bat]---------------------------------Start /wait CHKNTFS /d C:CHKNTFS /d D:CHKDSK /f /v /r /x D:CHKDSK /f /v /r /x C:===================You can add E or F if you have more partitions. Waht this does is it thouroughly checks your hard drive bit-by-bit to make sure you do not have orphaned file (or corrupted files). This command may take 2 to 8 hours depending on you hard drive size.Also use DEFRAGGLER to defragment drive once a week. If oyu have downloaded say files > 500MB, it can fragment your $MFT into 3 or more. To defragment $MFT, use PAGEDEFRAG which is part of SysInternal Suitehttp://technet.microsoft.com/en-us/sysinternals/bb842062.aspxhttp://download.sysinternals.com/Files/PageDefrag.zipDEFRAGGLER: http://www.piriform.com/This way you would not have problem checking disk but weekly or twice a month.
August 15th, 2010 10:13pm

---------------------------------Start /wait CHKNTFS /d C:CHKNTFS /d D:CHKDSK /f /v /r /x D:CHKDSK /f /v /r /x C:=================== Would it restart the window to perform chkdsk? when I run ckdkwk.bat file.Thank everyone very much for any suggestions
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 9:33am

I like your idea on using schtasks to perform 2 separate tasks.Do you have another simple approach on calling chkdsk?-------------------hib.bat------------------schtasks /delete /tn hib /fPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState------------------------------------------- ------------------chkdsk.bat-------------------------------Start /wait CHKNTFS /d C:CHKNTFS /d D:CHKDSK /f /v /r /x D:CHKDSK /f /v /r /x C:schtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------Do you have any suggestions on whether it works or not? I need to try it out on this weekend.Thank everyone very much for any suggestions
August 18th, 2010 9:37am

What is the purpose of starting the first command in the file in a separate window (Start /wait CHKNTFS /d C:)?Why use multiple chkntfs commands when a single one can globally reset the default behaviour on all the drives?Why use the /v switch when running unattended chkdsk?Assuming that C: is the boot volume (the Windows drive) then the CHKDSK /f /v /r /x C: command will choke as it will go unanswered. Furthermore, your batch file has no command to restart the computer so the boot volume will go unchecked until a manual restart is initiated.Downloading large files will not fragment the MFT unless the disk is running out of space, in which case the file system will relent and yield space for the files within the MFT zone. A large file uses no more MFT space than a small file, each file uses one MFT record and information which cannot be stored in the MFT entry is store in an non-resident attribute (ouside the MFT).PageDefrag cannot defragment the MFT.For most users defragmenting and running chkdsk on a weekly basis is excessive and a complete waste of time. John
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 3:07pm

---------------------------------Start /wait CHKNTFS /d C:CHKNTFS /d D:CHKDSK /f /v /r /x D:CHKDSK /f /v /r /x C:=================== Would it restart the window to perform chkdsk? when I run ckdkwk.bat file.Thank everyone very much for any suggestionsNo. The batch file is "half baked...".John
August 18th, 2010 3:09pm

I like your idea on using schtasks to perform 2 separate tasks.Do you have another simple approach on calling chkdsk?-------------------hib.bat------------------schtasks /delete /tn hib /fPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState------------------------------------------- ------------------chkdsk.bat-------------------------------Start /wait CHKNTFS /d C:CHKNTFS /d D:CHKDSK /f /v /r /x D:CHKDSK /f /v /r /x C:schtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------Do you have any suggestions on whether it works or not? I need to try it out on this weekend.Thank everyone very much for any suggestionsThe following: Start /wait CHKNTFS /d C:CHKNTFS /d D:CHKDSK /f /v /r /x D:CHKDSK /f /v /r /x C: is all wrong, none of that will do what you want. The first line (Start /WAIT) and the CHKDSK /f /v /r /x C: commands will choke the batch file.John
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 3:14pm

If I only chkdsk D: drive, which is data drive, can I apply your coding for scheduling task?I only need to do it one per bi-month for checking disk for any error.Batch file #1, (Copy the stuff between the --- lines ---): -------------------chkdsk.bat-------------------------------echo y|chkdsk D: /Fschtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------ Batch file #2. This is the hib.bat batch file that is scheduled to run when the computer starts after the chkdsk is done. The Schtasks command in the first batch file schedules the file to run. You must place the file in the location called by the Schtasks command, in the above command the file is called from C:\, place in that location or if you want to save it in another location change the chkdsk.bat file accordingly.-------------------hib.bat------------------schtasks /delete /tn hib /fPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState-------------------------------------------Thank everyone very much for any suggestions
August 18th, 2010 4:59pm

If you are only wanting to check the data drive and then hibernate the machine when done then the following single batch file will do it:-------------------chkDatVol.bat------------------chkdsk d: /f /xPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState-----------------------------------------------------The /X switch instructs chkdsk to dismount the volume if necessary.Do chkdsk /? at the command prompt for more help on chkdsk.The second Hib.bat file is only needed if you chkdsk the Windows drive, that is because the machinemust be restarted to run a boot time chkdsk on the boot volume, after chkdsk is done Windows starts normally, so you need an additional task to then hibernate the machine.John
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 5:25pm

[OS] The format for C: drive is NTSF, when I try to scan C: drive, it will only perform scanning when window restarts next time.[Data] The format for D: drive is NTSF, when I try to scan D: drive, it will only perform scanning when window restarts next time.[Data] I get another Z: drive is also NTSF, but when I try to scan Z: drive, it will perform scanning immediately without restarting window.It seems to me that Z: drive will work with chkDatVol.bat file, but D: drive will work with chkdsk.bat, because it requires restarting window, when I do it manually.I would try both files at this weekend to see how it works.Do you have any suggestions on why some data drive perform scanning immediately, but other requires to restart window to perform scanning?Thank everyone very much for any suggestions
August 18th, 2010 6:33pm

On 8/18/2010 12:33 PM, oem7110 wrote:[OS] The format for C: drive is NTSF, when I try to scan C: drive, it will only perform scanning when window restarts next time.[Data] The format for D: drive is NTSF, when I try to scan D: drive, it will only perform scanning when window restarts next time.[Data] I get another Z: drive is also NTSF, but when I try to scan Z: drive, it will perform scanning immediately without restarting window.It seems to me that Z: drive will work with chkDatVol.bat file, but D: drive will work with chkdsk.bat, because it requires restarting window, when I do it manually.I would try both files at this weekend to see how it works.Do you have any suggestions on why some data drive perform scanning immediately, but other requires to restart window to perform scanning?Open a command prompt and issue this command:chkdsk d: /fWhat is the exact message that you get?John
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 6:40pm

On 8/18/2010 12:33 PM, oem7110 wrote:[OS] The format for C: drive is NTSF, when I try to scan C: drive, it will only perform scanning when window restarts next time.[Data] The format for D: drive is NTSF, when I try to scan D: drive, it will only perform scanning when window restarts next time.[Data] I get another Z: drive is also NTSF, but when I try to scan Z: drive, it will perform scanning immediately without restarting window.It seems to me that Z: drive will work with chkDatVol.bat file, but D: drive will work with chkdsk.bat, because it requires restarting window, when I do it manually.I would try both files at this weekend to see how it works.Do you have any suggestions on why some data drive perform scanning immediately, but other requires to restart window to perform scanning?Open a command prompt and issue this command:chkdsk d: /fWhat is the exact message that you get?JohnI right click the D: drive and select property > Tools > Scandisk, and it requests restart window, D: is mainly installed application and data, which is not under command mode. I will try your batch files on this weekend.Do you have any suggestions? Thank everyone very much for any suggestions
August 18th, 2010 6:48pm

On 8/18/2010 12:48 PM, oem7110 wrote:On 8/18/2010 12:33 PM, oem7110 wrote:[OS] The format for C: drive is NTSF, when I try to scan C: drive, it will only perform scanning when window restarts next time.[Data] The format for D: drive is NTSF, when I try to scan D: drive, it will only perform scanning when window restarts next time.[Data] I get another Z: drive is also NTSF, but when I try to scan Z: drive, it will perform scanning immediately without restarting window.It seems to me that Z: drive will work with chkDatVol.bat file, but D: drive will work with chkdsk.bat, because it requires restarting window, when I do it manually.I would try both files at this weekend to see how it works.Do you have any suggestions on why some data drive perform scanning immediately, but other requires to restart window to perform scanning?Open a command prompt and issue this command:chkdsk d: /fWhat is the exact message that you get?JohnI right the D: drive and select property> Tools> Scandisk, and it requests restart window, D: is mainly installed application and data, which is not under command mode. I will try your batch files on this weekend.Do you have any suggestions?Don't do this with the GUI tools in Windows Explorer. Please run the command from a Command Prompt.To start a command session enter the following command in the Start menu Run box:cmdAt the Command prompt type this command and press <Enter>chkdsk d: /fWhat does the command return, be precise and give the exact message.John
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2010 6:54pm

Not able to execute chkdsk, because the disk is being used by other process.If you understand the disk, chkdsk may be able to execute.so all executed control code will be failed on this diskDo you want to force and release the disk? (Y/N)I translate the message from other language, so it is about the meaning of the message.Do you have any suggestions?Thank everyone very much for any suggestions
August 19th, 2010 3:11am

On 8/18/2010 9:11 PM, oem7110 wrote:Not able to execute chkdsk, because the disk is being used by other process.If you understand the disk, chkdsk may be able to execute.so all executed control code will be failed on this diskDo you want to force and release the disk? (Y/N)I translate the message from other language, so it is about the meaning of the message.Do you have any suggestions?Answer yes (type Y and press <Enter>) and force a dismount (release) of the disk.John
Free Windows Admin Tool Kit Click here and download it now
August 19th, 2010 3:39am

-------------------chkdsk.bat-------------------------------echo y|chkdsk D: /Fschtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------Can I run chkdsk on D: drive by adding following coding before it hibernates?So I can add D & Z drives for chkdsk.Do you have any suggestions?-------------------hib.bat------------------schtasks /delete /tn hib /fchkdsk d: /f /xchkdsk z: /f /xPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState-------------------------------------------Thank everyone very much for any suggestions
August 19th, 2010 6:07am

-------------------chkdsk.bat-------------------------------echo y|chkdsk D: /Fschtasks /create /tn Hib /sc onstart /tr c:\hib.bat /ru ""shutdown -r -f -t 0------------------------------------------------------------Can I run chkdsk on D: drive by adding following coding before it hibernates?So I can add D & Z drives for chkdsk.Do you have any suggestions?-------------------hib.bat------------------schtasks /delete /tn hib /fchkdsk d: /f /xchkdsk z: /f /xPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState-------------------------------------------Thank everyone very much for any suggestionsYou want to run a batch file to have chkdsk run on DATA drives D & Z and after chkdsk is done you want to hibernate the machine, right? Only one batch file is needed for this: -------------------chkDatVol.bat------------------chkdsk d: /f /xchkdsk z: /f /xPowercfg /h onRUNDLL32.EXE PowrProf.dll,SetSuspendState----------------------------------------------------- John
Free Windows Admin Tool Kit Click here and download it now
August 19th, 2010 2:16pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics