Solved

Using Regedit to force disk check at reboot

Posted on 2007-11-21
7
4,342 Views
Last Modified: 2010-04-21
I am creating an AutoIt script that produces a menu with shortcuts to frequently used programs I run to perform routine maintenance on the Windows XP-based computers at the office where I work.  One menu item will have the computer run error-checking on the hard drive when the computer reboots. The long way of doing this is double-click on My Computer, right-click on C, go to Properties, click on the Tools tab, click Check Now in the Error Check section and checking both items in the window that opens.

I know something's written to the registry for the error checking to take place when the computer reboots, but I don't know what entries these are or where they're written. I'd like my script to write these entries to the registry without having to go through the lengthy process I've described above.
0
Comment
Question by:mjbtec
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 20329210
See the description at http://support.microsoft.com/kb/218461 ("Description of Enhanced Chkdsk, Autochk, and Chkntfs Tools in Windows 2000"), that applies to XP as well. The scoop is to set

HKLM\System\CurrentControlSet\Control\Session Manager\ BootExecute:REG_MULTI_SZ: autocheck autochk *

You will find a description of the additional parameters in the article.
0
 
LVL 86

Expert Comment

by:jkr
ID: 20329268
BTW, why don't you just launch

chkdsk.exe c:

from your script?
0
 
LVL 3

Expert Comment

by:RealityLord
ID: 20330820
Hello.
You can set dirty bit, and on reboot windows will chkdsk targeted partition.
Something like this:

RunWait("cmd /c fsutil dirty set C:")

Hope it helps.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

by:lciprianionut
ID: 20331956
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager under BootExecute key

example from vista business (for C and H drives)

autocheck autochk /r \??\H:
autocheck autochk /r \??\C:
autocheck autochk *
0
 
LVL 86

Expert Comment

by:jkr
ID: 20332411
lciprianionut,

I am under the impression that this has already bee mentioned.
0
 

Author Closing Comment

by:mjbtec
ID: 31410410
That's exactly what I was looking for. I wanted my script to run the menu items invisibly in the background without any prompts popping up, so I didn't want to use CHKDSK.

I modified my AutoIt script to write the line in the registry for the error checking to take place on the next reboot and it worked like a charm when the computer restarted. Here are the lines from my AutoIt script that made it all happen.

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager", "BootExecute", "REG_MULTI_SZ", "autocheck autochk /r \??\C:")
MsgBox (4096, "MaintMan", "Scandisk will run next time you reboot.")

Thanks everyone for their help.
0
 

Author Comment

by:mjbtec
ID: 20350062
JKR, that was exactly what I was looking for. I wanted my script to work its magic invisibly in the background without any annoying prompts, so I didn't want to use CHKDSK.

I had my script write the lines to the registry to force the disk checking to take place when the computer restarted and it worked like a charm. Here are the lines from my script that made it all happen.

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager", "BootExecute", "REG_MULTI_SZ", "autocheck autochk /r \??\C:")
MsgBox (4096, "MaintMan", "Scandisk will run next time you reboot.")

Thanks everyone for their help.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now