Jump to content

How do I defrag and chkdsk at startup sequential?


bucketbuster

Recommended Posts

Hi,

does anybody know how I run chkdsk and immediately after that a defragmentation program (dirms) before XP starts or when it restarts?

I know I can use Task Scheduler to schedule chkdsk at startup, but is it possible to run another program right after?

I've read something about GuiRunOnce, but don't understand how to use it :blushing:

I want to make a batchfile that restarts my computer, at start up: 1.scans my harddrives for errors and fixes them,2.defrags my harddrives, (3. runs pagedefrag) and after that starts XP.

EDIT:

Finally figured it out :thumbup

Look here: http://www.msfn.org/board/index.php?showto...10entry254706

Link to comment
Share on other sites


I suppose one way to do it is to place each command in a separate hive or registry key which windows reads sequentially during startup. This is the sequential list in the order they are processed:

• BootExecute

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute

• Services

• User enters a password and logon to the system

• UserInit

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit

• Shell

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell

All Users-RunOnce

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce

• All Users-Run

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

All Users-RunOnceEx

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx

• All Users-RunEx

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunEx

Current User-RunOnce

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

• Current User-Run

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

• Current User-RunOnceEx

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnceEx

• Current User-RunEx

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunEx

• Common Startup Folder

• Startup Folder

The list came from this webpage http://www.greatis.com/security/startuporder.htm

Some information here may prove helpful to you http://www.ntcompatible.com/thread24145-1.html

Link to comment
Share on other sites

would it be accurate to say that dirms requires cmd.exe to be running for successful execution which means that cmd.exe is not available when bootexecute is called so a defrag program such as dirms will need to be set later in the boot process when cmd.exe is available. I don't know precisely where that would be.

Link to comment
Share on other sites

would it be accurate to say that dirms requires cmd.exe to be running for successful execution which means that cmd.exe is not available when bootexecute is called so a defrag program such as dirms will need to be set later in the boot process when cmd.exe is available. I don't know precisely where that would be.

You are probably right. :unsure:

I'm gonna test some other freeware defraggers (defragNT, PowerDefragmenter), hopefully I can get them to work.

Anyways, Thx for your help ;)

Link to comment
Share on other sites

would it be accurate to say that dirms requires cmd.exe to be running for successful execution which means that cmd.exe is not available when bootexecute is called so a defrag program such as dirms will need to be set later in the boot process when cmd.exe is available. I don't know precisely where that would be.

You are probably right. :unsure:

I'm gonna test some other freeware defraggers (defragNT, PowerDefragmenter), hopefully I can get them to work.

Anyways, Thx for your help ;)

No luck with DefragNT/Power Defragmenter :(

Anyone knows how to use UserInit or RunOnce?

Link to comment
Share on other sites

you can use diskeeper 8 or 9. select on change your settings then set a boot time defrag. select your c drive then check the options you want.

I know I could use Diskeeper or O&O Defrag or PerfectDisk...

But I only wanted to use FREEware and automate the whole proces. ;)

Link to comment
Share on other sites

I finally figured out how to do it!

In the attached zipfile you will find 6 files:

dirms.exe - the defragmentation tool

dirms.bat - batchfile to call dirms.exe with switches

pgdfgsvc.exe - pagedefrag

optimize.reg - registryentries needed for chkdsk,pagedefrag and dirms

optimize2.reg - restores the userinit-section

optimize.cmd - batchfile to start the optimization-proces

This is what optimize.cmd does:

1.merge optimize.reg into the registry, these items will be added to the bootexecute-section:

-chkdsk /F /R (=check C: for errors, repair them and check free space)

-pgdfgsvc -o (=defrags only at next boot)

1b.this will be added to the userinit-section:

-dirms.bat, userinit.exe (=needed to load your shell,DON'T remove it!!)

(dirms.bat runs dirms.exe c DEFRAG COMPACT)

2.Restarts your computer after 30 seconds, giving you time to save your work

Once the whole proces has finished, XP will be started.

Put all files except optimize.cmd in C:\WINDOWS\system32\

Put optimize.cmd on your Desktop or whereever you want..

NOTE:

I only added support for C:

Links to the used programs:

Dirms: http://www.dirms.com/

Pagedefrag: http://www.sysinternals.com/ntw2k/freeware/pagedefrag.shtml

Chkdsk: already installed with XP

I hope someone finds this as usefull as I do

EDIT:

Now it should work.

Optimize.zip

Edited by bucketbuster
Link to comment
Share on other sites

  • 1 month later...

something i have found to be very handy and alot better for scheduling a chkdsk and defrag in scheduled tasks. i have included 2 files. 1 doc to explain how to create the VBS file to launch the chkdsk/defrag combo that i run once a month, and the defrag.vbs i use weekly.

simply go to scheduled tasks and add new, browse for these files and add, be sure to look at advanced options and put a check in the run olnly if logged on box. youre done.

chkdsk_defrag.doc

Link to comment
Share on other sites

  • 3 weeks later...
I finally figured out how to do it!

In the attached zipfile you will find 6 files:

dirms.exe - the defragmentation tool

dirms.bat - batchfile to call dirms.exe with switches

pgdfgsvc.exe - pagedefrag

optimize.reg - registryentries needed for chkdsk,pagedefrag and dirms

optimize2.reg - restores the userinit-section

optimize.cmd - batchfile to start the optimization-proces

This is what optimize.cmd does:

1.merge optimize.reg into the registry, these items will be added to the bootexecute-section:

-chkdsk /F /R (=check C: for errors, repair them and check free space)

-pgdfgsvc -o (=defrags only at next boot)

1b.this will be added to the userinit-section:

-dirms.bat, userinit.exe (=needed to load your shell,DON'T remove it!!)

(dirms.bat runs dirms.exe c DEFRAG COMPACT)

2.Restarts your computer after 30 seconds, giving you time to save your work

Once the whole proces has finished, XP will be started.

Put all files except optimize.cmd in C:\WINDOWS\system32\

Put optimize.cmd on your Desktop or whereever you want..

NOTE:

I only added support for C:

Links to the used programs:

Dirms: http://www.dirms.com/

Pagedefrag: http://www.sysinternals.com/ntw2k/freeware/pagedefrag.shtml

Chkdsk: already installed with XP

I hope someone finds this as usefull as I do

EDIT:

Now it should work.

I have just downloaded this program, as I thought it to be the perfect addition to my unattended DVD.

The problem is that my Virtual Machine now is stuck in an infinite loop...

Could this be because I changed the hardcoded windows folder to %windir%?

Yup, changing the hardcoded to variables was the problem.

It's going along nicely now in VMWare :)

Link to comment
Share on other sites

  • 4 years later...

Greetings,

I hope someone will read this after so long... anyway here goes...

I am using WIN XP Media Center Edition

This is exactly the solution I have been searching for a long time.

I have never (manually) edited the registry so I am trying to proceed cautiously.

I may also have to modify the files in "optimize.zip"

I have a few questions:

[1] In the file "optimize.reg" why are the "BootExecute" entries in what appears to be hex?

[2] Is it possible to have those entries in plain text?

[3] Since "DIRMS" is no longer free, are there any free Command Line Defrag programs which can do a good job?

Thanks for any help (from anyone).

Edited by slowofmind
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...