Jump to content

Batch File for ChkDsk


theHammer

Recommended Posts

I run ChkDsk and a VBS Defrag script from a batch file once a week at night on my two home computers running XP-Home. Would like to add the /R and /F switches to the command line which requires that Chkdsk run upon the next boot. No problem could use GRC's Wizmo reboot to restart but do not want to stay up that late to answer the request for Y or N required. If you are with me this far just how might I force a ChkDsk /R /F without responding Yes to the question asked? Somehow this answer is remembered and ChkDsk run before Windows actually loads. In the old days DOS loaded first and you could run a batch file before Win was called. Need some leads to even ask a more intelligent question.Ed

Link to comment
Share on other sites

Guest PrivateDancer

would this free batch file builder work for you (is xp compatible btw) ? D/L hereIt's nifty, fast, clean - like your own batch file cheat sheet!program i normally use when too stupid or too lazy write my own batches - easier faster write them in C++ with wysiwug - maybe you'll find it useful ? info & D/L here

Link to comment
Share on other sites

I am pretty comfortable with batch files but your reference looks interesting and will download and study (am retired so have the time<g>). I suspect the program simply simplifies writing a batch file; unless they found some way of responding to prompts from what I call DOS commands like XCOPY which in this case requires a Y or N key press to proceed. I suspect I need to get to the file that is read on boot and details the need for running a chkdsk.Ed

Link to comment
Share on other sites

Guest PrivateDancer

didn’t mean to insinuate you couldn’t write own batch files just both programs allow you to configure switches so you can walk away at night & it will run progs in specified order to completion with the responses placed in proper format so is truly unattended

Link to comment
Share on other sites

Had to indicate I was comfortable with batch files but now I must admit this old brain is slowing - forgot all about either redirecting or piping the response - and yes Ed echo Y works with XP.Jeffw my plan I believe solves your question. I intended to use Gibson's (www.grc.com) wizmo reboot as the last instruction in my batch file and kick it off using System Scheduler in the middle of the night.Unfortunately I see several remaining problems. No problem with C drive where I have my OS - it just states in use and the question do I want to run upon next boot. However I get two questions from ChkDsk on my D partition which is where I keep my programs and data. Both indicate the volume is in use by another process but the first question is would I like to "dismount." Not ever having been on a horse I have no idea if I want to<g>. It indicates "all handles will be invalid" - doesn't sound good<g>. Now I don't think I can pipe or redirect two responses to a single dos command but taking it one step at a time what are the consequences of "dismounting"?Now I also have an E drive where I archive and it just fires with chkdsk e: /f /r so would run it first, then echo Y | chkdsk c: /f /r followed by wizmo reboot so that it would fire. Appreciate some education on "horses" and then I can run some trials there.Ed Ed

Link to comment
Share on other sites

Got something working but can not explain totally. With automation so simple not worth further investigation.Using ideas gained here one night I will run a thorough chkdsk with /r and /f switches (and solved the double question problem by simply adding a force with /x) on one night with this batch file fired early in the morning. On rebooting it does its jobecho y | chkdsk C: /r /f /xecho y | chkdsk D: /r /f /xc:\windows\system\wizmo.exe rebootOn the next night I will run a second batch file with chkdsk E: /r /f followed by a defrag script to handle all three partitions.When I try to group the two I run into errors which befuddle.Lastly, jeffw asks why I want to do... the chkdsk does periodically pick up problems in the file structure and corrects, the defrag can't hurt and may just speed up things - and it is all done free at night.Ed

Link to comment
Share on other sites

i don't know - on win98se defrag tended to mess up my system, so I only did it semi-annually - not sure i need it more often under XPthe chkdsk strategy seems interesting - might do it weekly (i assume the wizmo is just a shutdown program? - I prefer POWEROFFthanks!/j

Link to comment
Share on other sites

my D partition which is where I keep my programs and data. Both indicate the volume is in use by another process but the first question is would I like to "dismount."
Mounting and dismounting (mapping) is usually associated with access to remote drives. It sounds like you have enabled that function with your D: drive and since the D: drive is a part of the hard drive in your pc it doesn't need to be mounted. Dismounting it should have no effect. The key word is "should". Not knowing what apps you run and etc it is possible an old DOS app needs the D: drive mounted but there's a 90% chance dismounting will have no effect. ^_^ Edited by EdP
Link to comment
Share on other sites

Try this...http://www.jsiinc.com/SUBA/tip0000/rh0058.htmWhat I'D really like to do is run a regular chkdsk that schedules a chkdsk /f for next boot  - if necessary-  and then causes the boot.anyone figured out how to do this?
Yes. In the chkboot.bat file add the command shutdown:
 chkdsk C: /F <c:\y.txt or chkdsk C: /F /R <c:\y.txtshutdown -r -t xxexit

where xx is the time in seconds before shutting down. But unless you want a shutdown window counting down for more than a few seconds, I'd add chkboot.bat to the Task Scheduler and have it run whenever you want.

Link to comment
Share on other sites

I don't have much to add that has not been mentioned before except for this. Why would you want to do weekly chkdsk's if they are not needed? Especially unattended ones. I for one have had more than one drive erased by chkdsk under NTFS.I can see wanting to run diskeeper bi-weekly under heavy use.Chris

Link to comment
Share on other sites

well that's a switch - under 98SE i avoided defrag because it messed things up, now under XP I should avoid chkdsk for the same reason - can't Msoft get anything right 8-}.Seriously, i think many of us just have ingrained from win98/me that daily scandisk=good so we want to find a a way to do it under XP - the fact that they make it difficult should, perhaps, be a red flag, but.....(ps - i'm still on FAT32 - does anyone knowif there are problems with chkdsk and fat32?)/j

Link to comment
Share on other sites

  • 1 year later...

I wonder whether anyone remembers how to make batch program respond to an external file. I wrote a batch program to run chkdsk on my computer on each of the partitions. For some partitions a message about running the program after the computer boots, but it requires a keyboard reply. I want the batch file to look at an external file for the Y or N to the question. I remember doing that a lont time ago but I don't remember how now. I think it used the >> or << .Jim

Link to comment
Share on other sites

Have you tried using fsutil to set the volume(s) dirty bit(s)?

fsutil dirty set c:fsutil dirty set d:

According to MS, "Every time Windows XP starts, Autochk.exe is called by the Kernel to scan all volumes to check if the volume dirty bit is set. If the dirty bit is set, autochk performs an immediate chkdsk /f on that volume. Chkdsk /f verifies file system integrity and attempts to fix any problems with the volume." That should remedy half of the problem, as chkdsk /f should run at the next boot without user intervention.Link

Link to comment
Share on other sites

RichNRockville
I wonder whether anyone remembers how to make batch program respond to an external file. I wrote a batch program to run chkdsk on my computer on each of the partitions. For some partitions a message about running the program after the computer boots, but it requires a keyboard reply. I want the batch file to look at an external file for the Y or N to the question. I remember doing that a lont time ago but I don't remember how now. I think it used the >> or << .Jim
in a batch file, the < means accept input from that file name.ie.chkdsk <y.txt would accept whatever is in the file y.txt for any keyboard inputs.make sure that Y.TXt has the letter Y in the first line of the txt file.>> will take screen output and append to an existing file or creat a new one with that name.chkdsk <y.txt >>results.txtRich
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...