Marl64 Posted September 13, 2004 Share Posted September 13, 2004 Wasn't sure if this was an unattended thing or an Application switches things so forgive me if I'm it's in the wrong place, "I'm new here" I looked through all the diskeeper threads and they're all about installing it, none seem to be about using it so here you go.WHY?Your custom install has completed, you've put on all your apps and deleted all the surplus windows dross, you've done your cleanup and your system is all ready to go.Except with all that messing, your drive is chewed up beyond belief. So the first thing you do is run diskeeper to defrag the thing. After every install.So why not do it automatically?THE LOGICDiskeeper does two main type of defrag;- The standard one with the pretty display - which tidies up your files and folders and makes all the red bits go blue- The Boot time one which runs before windows has grabbed everythingIdeally you want to do both, and ideally you want the boot one to go first.But the boot one runs at boot time and resets when it's done, so we need to mess about a bit.(If there's anyone there from executive software who knows a better way, please feel free to jump in anythime )THE FLY IN THE OINTMENTOnly one for now, the registry entry that diskeeper uses to call the boot time routine is stored in the "BootExecute" key in [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager] , this is a multi string key (REG_MULTI_SZ) and as this can't (as far as I know) contain expandable strings, the drive reference is absolute. So I have to fiddle it with multiple .reg files for now 'cos I haven't done a dynamic key generating thingy yet.THE METHODOk, this is my first working version so it might not be the best way to do a lot of stuff, but it definately works and I happy with that much.I do intend to tidy it up a little, but keep thinking of that expression "if it 'aint broke, don't fix it"It assumes you have installed diskeeper and will do a forced reset after your cleanup routine. 1. The Files In a folder (I use the usual \Install\Diskeeper), you have the following files;DEFRAGME.DAT - an empty file used by diskeeperFRAG1.CMD - The File you call from your normal installFRAG2.CMD - The File that handles the second part of the defragFRAG1.REG - The Registry key used by FRAG1 FRAG2.REG - The Registry key used by FRAG2FRAG_C.REG - Reg key with fixed drive reference to C:FRAG_D.REG - Reg key with fixed drive reference to D:etc.2. Setting upCall FRAG1.CMD from your normal install routine after diskeeper is installed.FRAG1.CMDTITLE - Schedule Defrag -SET MYLOG="%UserProfile%\Desktop\Install.Log"SET INSTALL=%systemdrive%\InstallECHO ... Queuing a Boot time defragment of Drive %systemdrive% ...REM - First we copy the batch file and reg entry needed for stage 2copy /Y %install%\Diskeeper\FRAG2.* %systemdrive%\ REM - We set an entry in the Run section of the registry to call stage 2start /wait regedit /s %install%\Diskeeper\FRAG1.regREM - Check if we have a drive specific Reg File and if so apply itIF EXIST "%INSTALL%\Diskeeper\Defrag_%systemdrive:~0,1%.reg" ( copy /Y %install%\Diskeeper\defragme.dat %systemdrive%\ start /wait regedit /s %INSTALL%\Diskeeper\Defrag_%systemdrive:~0,1%.reg ECHO Two Stage Boot time Defrag Queued ECHO %TIME% - - Two Stage Boot time Defrag Queued >>%MYLOG%) ELSE ( ECHO Second Stage Defrag Queued ECHO %TIME% - - Second Stage Defrag Queued >>%MYLOG%)ECHO.(NB: "%systemdrive:~0,1%" Returns the System Drive Letter without the colon so that it can be used to pick up the correct .reg file)FRAG1.REGWindows Registry Editor Version 5.00; Queue The Autorunning of the second stage Defrag; (whether or not the First - boot stage will be done);; this bit says "CMD /C "IF EXIST %systemdrive%\FRAG2.CMD CALL %systemdrive%\FRAG2.CMD"[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]"Frag2"=hex(2):43,00,4d,00,44,00,20,00,2f,00,43,00,20,00,22,00,49,00,46,\ 00,20,00,45,00,58,00,49,00,53,00,54,00,20,00,25,00,73,00,79,00,73,00,74,00,\ 65,00,6d,00,64,00,72,00,69,00,76,00,65,00,25,00,5c,00,46,00,52,00,41,00,47,\ 00,32,00,2e,00,43,00,4d,00,44,00,20,00,43,00,41,00,4c,00,4c,00,20,00,25,00,\ 73,00,79,00,73,00,74,00,65,00,6d,00,64,00,72,00,69,00,76,00,65,00,25,00,5c,\ 00,46,00,52,00,41,00,47,00,32,00,2e,00,43,00,4d,00,44,00,22,00,00,00I use Run because a RunOnce entry would be removed before it got chance to run.OK, so we've got the second part queued and that will run whether or not the first (boot time) stage is run. So onto that.DEFRAG_C.REGWindows Registry Editor Version 5.00; Call for diskeeper to do a boot time defrag...[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager]"BootExecute"=hex(7):61,00,75,00,74,00,6f,00,63,00,68,00,65,00,63,00,6b,00,20,\ 00,61,00,75,00,74,00,6f,00,63,00,68,00,6b,00,20,00,2a,00,00,00,41,00,55,00,\ 54,00,4f,00,4e,00,54,00,46,00,53,00,20,00,43,00,3a,00,20,00,50,00,41,00,47,\ 00,45,00,3d,00,4d,00,49,00,4e,00,20,00,44,00,49,00,52,00,53,00,3d,00,4d,00,\ 46,00,54,00,5a,00,20,00,4d,00,46,00,54,00,3d,00,4d,00,49,00,4e,00,20,00,00,\ 00,00,00What this is actually saying is autocheck autochk *AUTONTFS C: PAGE=MIN DIRS=MFTZ MFT=MINThe first line belongs to windows, the second to diskeeperThis example is for drive C, to change it to use in "DEFRAG_D.REG", "DEFRAG_E.REG" etc. you need to change the drive letter reference (43) - 3rd line down, 15th Byte across (between 20 00 and 00 3a) - to the correct number;C = 43D = 44E = 45etc.You can have as many as you like, FRAG1 will only use the correct one if it's there.3. Second StageThe second stage command file (%SYSTEMDRIVE%\FRAG2.CMD) needs to check if the first stage (boot time) defrag has completed - remember "DEFRAGME.DAT"? Well Diskeeper deletes this once the boot time defrag has run.Also if there wasn't a valid .reg file for the system drive, and the first stage wasn't queued "DEFRAGME.DAT" Won't exist. Works both ways.DEFRAG2.CMD@ECHO OFFTITLE - Second Stage Defrag - SET MYLOG="%UserProfile%\Desktop\Install.Log"REM - Only do the full defrag if the boot one is not queuedIF NOT EXIST %SYSTEMDRIVE%\defragme.dat ( ECHO %TIME% - Second Stage Defrag Started >>%MYLOG% ECHO - Second stage Defragmenting of %SYSTEMDRIVE% ECHO. ECHO There may be a short delay while we wait for the service to start ECHO. diskeeper %SYSTEMDRIVE:~0,1% start /wait regedit /s %systemdrive%\FRAG2.reg DEL /q /f %SYSTEMDRIVE%\FRAG2.reg ECHO %TIME% - Second Stage Defrag Finished >>%MYLOG%) ELSE ( ECHO %TIME% - Second Stage Defrag Skipped >>%MYLOG% ECHO (First Stage not yet run) >>%MYLOG%)IF NOT EXIST %SYSTEMDRIVE%\defragme.dat DEL /q /f %0FRAG2.REGWindows Registry Editor Version 5.00; Remove the Run Command that called Frag2[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]"Frag2"=-So what this does is waits until the file is gone, defrags the system drive, clears the registry entry and cleans up after itself.FRAG2.reg is the best place to activate any registry monitoring utils. Until now they would have got upset with all my fiddling so mine also has the following; Activate Adwatch & Adaware; NB: Adaware uses absolute References, but the version below uses expanding string; reg keys to keep it drive independant.; "%ProgramFiles%\Ad-aware 6\Ad-aware.exe" +c; "%ProgramFiles%\Ad-aware 6\Ad-watch.exe"[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]"Ad-aware"=hex(2):22,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,\ 00,6c,00,65,00,73,00,25,00,5c,00,41,00,64,00,2d,00,61,00,77,00,61,00,72,00,\ 65,00,20,00,36,00,5c,00,41,00,64,00,2d,00,61,00,77,00,61,00,72,00,65,00,2e,\ 00,65,00,78,00,65,00,22,00,20,00,2b,00,63,00,00,00"Ad-watch"=hex(2):22,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,\ 69,00,6c,00,65,00,73,00,25,00,5c,00,41,00,64,00,2d,00,61,00,77,00,61,00,72,\ 00,65,00,20,00,36,00,5c,00,41,00,64,00,2d,00,77,00,61,00,74,00,63,00,68,00,\ 2e,00,65,00,78,00,65,00,22,00,00,00Oh and remember not to delete FRAG2.CMD and FRAG2.REG during your normal cleanup, they are self cleaning Summary1. The defrags are queued during normal installation the system reboots2. First reboot, Diskeeper does a boot-time defrag and reboots3. Windows loads normally when reaches the desktop calls diskeeper to do a full defrag4. The registry is reset and the files removed.Your newly installed system has a defragged system drive.Well it worked for me, I hope someone else finds it useful. Link to comment Share on other sites More sharing options...
idle.newbie Posted September 14, 2004 Share Posted September 14, 2004 GOOOOOD...i'd read some thread that generate 5k x 5k folders and each folder has 10k empty files, these folders and files are used to increase the MFT size. after deleting all these folders and files, the MFT size remains, then invoke the defragmenter, and he said you don't need any defragmenter anymore(for NTFS).i can't remember where the thread was, the .cmd script was lost, maybe rewrite a .cmd script before your guide will be a good idea, worth a try. Link to comment Share on other sites More sharing options...
MHz Posted September 14, 2004 Share Posted September 14, 2004 Here is a regtweak for MFT:; MasterFileTable Sizing - 1=Default 2=Medium 3=Larger 4=Maximun; ======================[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]"NtfsMftZoneReservation"=dword:00000001Apparently 1 is 12.5%, 2 is 25%, 3 is 37.5% & 4 is 50%.May be useful. Link to comment Share on other sites More sharing options...
sixpack Posted September 15, 2004 Share Posted September 15, 2004 thanks works greatbut how to call this from cleanup.cmdi ask because i use RunOnceEx.cmd and then cleanup.cmdso my system reboots after the cleanupso i whant to call it from thereany tips edit: never mind found a way Link to comment Share on other sites More sharing options...
Powerhouse Posted October 24, 2004 Share Posted October 24, 2004 Sixpack,Could you post how you ran it from Cleanup.cmd. Also, is the Boot optimization in Diskeeper better than using Bootvis? Or are they both separate beasts...? Link to comment Share on other sites More sharing options...
sixpack Posted October 24, 2004 Share Posted October 24, 2004 from cleanup.cmd:ECHO.CALL %systemdrive%\install2\Applications\Diskeeper\FRAG1.CMDi made a install2 file in $OEM$\$1 with the filesthe Boot optimization in Diskeeper is better i thinkbtw i use now diskeeper 9 and it doesend seam to work any more so back to v8edit: i did modi. the files so if you want you can download themedit2: works now with v9 i ad this in FRAG2.CMD:"%systemdrive%\Program Files\Executive Software\Diskeeper\DkService.exe"install2.rar Link to comment Share on other sites More sharing options...
Powerhouse Posted October 24, 2004 Share Posted October 24, 2004 Did you modify the files to work with Diskeeper 9? Link to comment Share on other sites More sharing options...
sixpack Posted October 24, 2004 Share Posted October 24, 2004 Did you modify the files to work with Diskeeper 9?i did modify them to work from install2for disk. v9: the cmd calls diskeeper the file name's are the same and now the funny partsome times it works and some time's it donterror mess. : cant start diskeeper service [in v9] Link to comment Share on other sites More sharing options...
Powerhouse Posted October 24, 2004 Share Posted October 24, 2004 What do these commands do?copy /Y %Install2%\Applications\Diskeeper\FWALL.reg %systemdrive%\ECHO.copy /Y %Install2%\Applications\Diskeeper\enable SCenter.reg %systemdrive%\I see no FWALL.reg or SCenter.reg in the file you have posted. Also, Why do you use Install2\applications? Is this where you install your files from from RunOnceEX, or are you copying files here, to prevent Cleanup.cmd from deleting the files? Link to comment Share on other sites More sharing options...
sixpack Posted October 24, 2004 Share Posted October 24, 2004 What do these commands do?copy /Y %Install2%\Applications\Diskeeper\FWALL.reg %systemdrive%\ECHO.copy /Y %Install2%\Applications\Diskeeper\enable SCenter.reg %systemdrive%\I see no FWALL.reg or SCenter.reg in the file you have posted. Also, Why do you use Install2\applications? Is this where you install your files from from RunOnceEX, or are you copying files here, to prevent Cleanup.cmd from deleting the files?... you can delete that it was to enabele the firewall againi use install2 because cleanup cmd delete's the install folderand there is no way to use that folder for the diskeeper file's so i made install2this way it defrags after the second logon Link to comment Share on other sites More sharing options...
WwTIPPYwW Posted October 24, 2004 Share Posted October 24, 2004 THE FLY IN THE OINTMENTOnly one for now, the registry entry that diskeeper uses to call the boot time routine is stored in the "BootExecute" key in [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager] , this is a multi string key (REG_MULTI_SZ) and as this can't (as far as I know) contain expandable strings, the drive reference is absolute.So I have to fiddle it with multiple .reg files for now 'cos I haven't done a dynamic key generating thingy yet.not sure if this is the same thing - the DOS command REG ADD can have variable paths. Just need to do a .CMD file and not a .REG file Link to comment Share on other sites More sharing options...
nateklomp Posted October 29, 2004 Share Posted October 29, 2004 Ideally you want to do both, and ideally you want the boot one to go first.Executive says in their doc that a full defrag should be completed BEFORE boot-time (MFT) defrag, not the other way around. Link to comment Share on other sites More sharing options...
Marl64 Posted November 17, 2004 Author Share Posted November 17, 2004 Ideally you want to do both, and ideally you want the boot one to go first.Executive says in their doc that a full defrag should be completed BEFORE boot-time (MFT) defrag, not the other way around.Really? I have always found the reverse works better.Often the main defrag is hampered by directories dotted all over the place, directories it seems reluctant to do anything with - presumably because windows has got it's sticky hands on them Running the boot one first gets these all into one place out of the way, giving the main one the rest of the disk to do with as it will. But the pig that annoys me is the reserved space, that Diskeeper will not touch and XP will not release. I've got system restore off, trashcan to rock bottom and still there's this dirty great swathe of real estate that the builders won't go near. "sorry mate, it can't go there, it's reserved see, by orders of da' management!" Link to comment Share on other sites More sharing options...
prathapml Posted January 18, 2005 Share Posted January 18, 2005 This is a great guide, thanks! Link to comment Share on other sites More sharing options...
sixpack Posted January 18, 2005 Share Posted January 18, 2005 This is a great guide, thanks!umm.. and old to Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now