Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Using Regedit to force disk check at reboot

Posted on 2007-11-21
7
4,373 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
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…
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…

790 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