1

I am writing a line-of-business utility that will, among other tasks, run chkdsk.exe in read-only mode on NTFS secondary data hard disks. To fully test my utility I need to induce a state on one of these disks which chkdsk will detect as an error... preferably in a way that does not destroy existing data on the disk. What is the easiest way to do this?

Edit:

Ideally I'd like to create a dummy text file on one of these drives and then mess up that file in such a way that chkdsk thinks it needs to be fixed. I'm not sure how to go about messing up a file.

2 Answers 2

2

You can simply give an invalid command-line:

c:\>chkdsk FailPlease
The drive, the path, or the file name is not valid.
c:\>echo %ERRORLEVEL%
3
1
  • Definitely a simple way to accomplish what I asked, so upvote for that. However I'd have to hard-code an incorrect volume name which isn't exactly what I'm looking to do. Thanks for helping me clarify my question.
    – Jared
    May 7, 2012 at 20:53
1

I think you want something that can reliably mount filesystem as a drive from a corrupted (or pseudo-corrupted state). First thing that comes to my mind is TrueCrypt

Now your script can make a copy of the image, mount the copy, let chkdsk attempt to fix, and then blow your image away.

2
  • Mounting an unformatted file container might be the way to go, though I'm hoping there's an easy way to mess up a dummy file on the actual disk. Thanks for helping me clarify my question.
    – Jared
    May 7, 2012 at 20:55
  • Well, with an image file, you could go about randomly changing bytes in the image and see what happens. You don't even need to use TrueCrypt, you could use something like ImDisk and work with non encrypted containers.
    – afrazier
    May 7, 2012 at 23:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .