Jump to content

Check if chkdsk has finished running in cmd


Recommended Posts

I need to run chkdsk for each drive volume in a server and fix any error. The steps are as follows:

  1. For each drive, run chkdsk without /f
  2. If there are disk errors to be fixed, run chkdsk again with /f
  3. If prompted, enter "n" to dismount and "Y" to run chkdsk when the computer reboots
  4. Repeat for next drive

I found this forum post that gives a solution to read the cmd output and send input when prompted. It depends on checking @error for StdoutRead in an infinite while-loop to determine if there is no more output, but some drives in my servers can take a long time to complete this check, without any new output for minutes. I don't want my script to prematurely detect that chkdsk is complete when it actually hasn't. How can I do that?

This is for a Win2K server environment. I can't replicate faulty hard disks in my development environment and it's not feasible to do too much trial and error at the client's environment, so I prefer to get as much of this right as possible before my first chance to test it.

 

Edited by thegreatjedi
Link to comment
Share on other sites

  • Moderators

@thegreatjedi welcome to the forum. Please note this forum is dedicated to helping you write and improve your scripts; it is not a forum where you put in a request and someone writes it for you. You will receive much more help if you post your code to show what you have tried on your own up to this point. Forum members can then offer suggestions for improvement.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...