Link to home
Start Free TrialLog in
Avatar of filtrationproducts
filtrationproductsFlag for United States of America

asked on

Bat file command to run CHKDSK

I had a .bat file that I used to run a chkdsk and defrag after the completion of a backup.  For some reason that file is missing and I did not create a back up of it. I have the defrag part completed below. But I cannot get the chkdsk command part to work.

I have tried
chkdsk e: /f
chkdsk e: /x

When I run the bat file with either of these the bat file opens a command prompt and it just loops at the chkdsk command. Does anyone know the syntax to get chkdsk to scan from a bat file?

(FYI - I cannot use windows scheduler, this needs to run through a backup program linked to the bat file)
echo
<<chkdsk command to go here>>
defrag e:
pause

Open in new window

Avatar of zelron22
zelron22

Avatar of filtrationproducts

ASKER

That does not work either, that also just makes it loop and scroll at the chkdsk command.

I know this is possible. I had this setup for 2 years and it worked perfectly. I remember it was a very simple command.
ASKER CERTIFIED SOLUTION
Avatar of zelron22
zelron22

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Knight
Did you call it either

chkdsk.cmd or defrag.cmd?  If so it will be re-runnin itself ahead of the exe.

Steve
This was the command. I tried it on my XP workstation and it worked fine. But on the Windows 2003 SBS server I had to change to the c:\windows\system32 directory before running the chkdsk command. Once I added "cd c:\windows\system32" right before the chkdsk command it began working.
Curious but did that stop it looping, or did you just mean it was pausing for a "Yes" to dismount the volume - /X should do that?
Steve
No, it wasn't pausing for a Yes to dismount the volume. I think it was looping because it couldn't find the chkdsk.exe file. Once I changed directories the looping stopped. I also did add a /x to dismount. It ran last night and was sitting at the "Yes/No" prompt this morning.