Solved

Using Regedit to force disk check at reboot

Posted on 2007-11-21
7
4,363 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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