Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

XP-Janitor: Checkdisk and defrag by script


  • Please log in to reply
15 replies to this topic
Boskoop
  • Members
  • 75 posts
  • Last active: Jan 11 2011 09:12 PM
  • Joined: 01 Jan 2005
The script "Janitor" launches Checkdisk and Defrag. When done, it shuts the computer down. Starting the script using Windows Scheduled Tasks helps automatize this boring tidy up. It is possible to start virus scanners and spyware scanners from this script too.

Configuration:
YesLetter:
If you use a non-english Windows, you might have to change the content of the variable "YesLetter". The command-line tool chkdsk needs a confirmation before starting. This is normally the first letter of the word "yes" in the systems default language (for example Y in english, J in German and so on)

ExitCommand:
By default (ExitCommand= ) the script ends with shutting the computer down/PowerOff. If you want to other software (for example for Suspend/ Hibernate instead of Shutdown), add the full path here.
Example:
ExitCommand=c:\WINDOWS\NOTEPAD.EXE.

LogFile, TimeStamp, PartingLine:
LogFile: Name of the log file
TimeStamp: Time and date, written into the logfile
PartingLine: Line to separate the logs from different Janitor-runs

Drives:
This script checks and defrags only drive C.
If you want to check other drives too, duplicate the following line:
runwait, cmd /c  echo %YesLetter% | chkdsk.exe c: /f /x >> %Logfile%, , min
and replace the C: with another drive-letter. Each drive needs an own line of code
If you want to defrag other drives too, duplicate the following line:
runwait, cmd /c defrag c: /v >>%Logfile%, , min
and replace the C: with another drive-letter. Each drive needs an own line of code

How this script works:
This script uses command line tools "cmd", "defrag" and "chkdsk" shipped with windows. Syntax and parameters er described in the Windows help file.

Checkdisk should be performed before defrag. Checkdisk often requires rebooting. So how do I get the computer to remember the waiting defrag-task after a reboot? I solved this by using the fileappend-command to write a complete ahk-script into the Startup-folder. This script is launched after reboot. The first thing this script does is to delete itself from the Startup-folder again. The script's ghost in RAM launches the defrag-task and, after finishing, shuts down the computer.

WARNINGS , LIMITATIONS
1. I tested this script on 2 computers with Windows XP Home and it worked fine. I don't know if the command line tools "defrag" and "chkdsk" are identical on Windows 9x or Windows 2000. If not, the script won't work or do unexpected things.

2. A defrag-run can take very long time. It needed 2 hours for my (rather crowded) 20 GByte FAT32 harddisk! I am not sure if files can be damaged when aborting a defrag-run (maybe someone knows more about that?). I recommend patience or a rather small harddisk/partition when playing around with the script.

3. The script requires an administrator-account (chkdsk doesn't work with other accounts)

4. The Defrag-part of the script starts after logon. If you have to log on with a password, it won't run completely unattended. A workaround is to use "Autologon", provided by TweakUI. (Does anybody know a way to start software before logon?)

Boskoop
; ---------------------------------------------------------------------
; Name:				XP_Janitor             
; Author:           Boskoop
; Datum:            21.8.2004
;
; Language:         english
; Platform:         tested with XP Home
; AHK-Version:		1.0.35.16
; #Includeable:     
;
; Description:		
; Starts first "checkdisk" and then "defragmentation" on harddisks.
; When finished, it shuts the computer down and turns the power off by default.
; If you want to suspend/hibernate the computer you can start another script/
; software instead.
; ---------------------------------------------------------------------



; ---------------------------------------------------------------------
; -- Configuration: ---------------------------------------------------
; --------------------------------------------------------------------
YesLetter=Y			;First letter of the word for "Yes" in the systems default language
ExitCommand=		;Full path of what you want to start when the script is finished. Shutdown, when empty
Logfile=%A_Scriptdir%\JanitorLog.txt
TimeStamp=%A_DD%-%A_MM%-%A_YYYY%  %A_Hour%:%A_Min%`n
PartingLine=`n`n****************************************************`n

; ---------------------------------------------------------------------
; -- Autoexecute: ---------------------------------------------------
; --------------------------------------------------------------------

Msgbox,1, , This computer will reboot in 10 seconds for checkdisk and defrag.`nTo abort press "Cancel", 10
	IfMsgBox, Cancel
		Exit
Fileappend,%PartingLine%%TimeStamp%, %Logfile%
runwait, cmd /c  echo %YesLetter% | chkdsk.exe c: /f /x >> %Logfile%, , min
Gosub Write_DefragAll
shutdown, 2
exit		

; ---------------------------------------------------------------------
; -- Subroutines: ---------------------------------------------------
; --------------------------------------------------------------------
Write_DefragAll:
; Uses the "Fileappend"-command to write the following complete AKH-script(DefragAll.ahk) 
; into the Startup-folder.
; DefragAll.akh deletes itself from the startup-folder, starts defragmentation and 
; shuts the computer down.

IfExist %A_StartupCommon%\DefragAll.ahk
	Filedelete %A_StartupCommon%\DefragAll.ahk

Fileappend, 
(
Filedelete, %A_StartupCommon%\DefragAll.ahk
SplashImage, , b fs18 x0 y0 CWFF0000,  Defrag is running!
runwait, cmd /c defrag c: /v >>%Logfile%, , min
SplashImage,Off
Gosub,ExitSub
exit

ExitSub:
	ExitCommand=%ExitCommand%
	If ExitCommand=
		{
		Msgbox,1, , Shutdown and Power Off in 10 seconds.``n To abort press "Cancel", 10
		IfMsgBox, Cancel
			Exit
		IfMsgBox, Timeout
			Shutdown,9
		IfMsgBox, OK
			Shutdown,9
		}
	Else
		{
		Msgbox,1, ,%ExitCommand% will be executed in 10 seconds.``n To abort press "Cancel", 10
		IfMsgBox, Cancel
			Exit
		IfMsgBox, Timeout
			Run, %ExitCommand%
		IfMsgBox, OK
			Run, %ExitCommand%
		}

),%A_StartupCommon%\DefragAll.ahk
return



evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
"Does anybody know a way to start software before logon?" - I've not done it myself, but I believe there is at least one program out there that can make a specified program run as a service - that might run before logon.

songsoverruins
  • Members
  • 46 posts
  • Last active: Sep 25 2015 08:43 PM
  • Joined: 01 Oct 2005
Has anybody tested this for running checkdisk on multiple drives? Running checkdisk on the C-drive requires a reboot as mentioned. Will the script continue with checkdisk for the other drives after the reboot before starting defragmentation on all drives or not?
For the music lover who can sit and enjoy the sound of someone else's evolving nightmare.

Boskoop
  • Members
  • 75 posts
  • Last active: Jan 11 2011 09:12 PM
  • Joined: 01 Jan 2005
@songsoverruins

Has anybody tested this for running checkdisk on multiple drives?


If you want to defrag other drives too, duplicate the following line:

runwait, cmd /c defrag c: /v >>%Logfile%, , min

and replace the C: with another drive-letter. Each drive needs an own line of code
On my to computers, all disks are checked. Windows XP logs all checkdisk-runs.

@evl
Windows XP professional has a command line taskplanner which is able to start software after system start and before logon. That tool works fine on XP Home too (even if it comes from an XP in another language version!), but I am not sure if this sort of transplantation is legal.
Either way- it is obviously possible to start software before logon- but I am missing the right tool for it.

Boskoop

mbirth
  • Members
  • 40 posts
  • Last active: Jul 31 2008 11:12 AM
  • Joined: 03 Oct 2005
Guys, take a look at http://www.mstsoftware.com . mst Defrag keeps your harddisks defragmented. If you write a file to disk, it will defragment it within the next 5 minutes. No more waiting for Microsoft's Defragger to finish.

I'm not related to the company in any way, but I'm using mst Defrag for several months now and it's a great thing. You should check it out.

Cheers,
-mARKUS

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
I have been using diskeeper for seven years now. In its set-it-and-forget-it mode it continuously defragment your selected disk drives in the background. In my setup it works when the screen saver is active, so it never slows the system down, when I work.

mbirth
  • Members
  • 40 posts
  • Last active: Jul 31 2008 11:12 AM
  • Joined: 03 Oct 2005

I have been using diskeeper for seven years now. In its set-it-and-forget-it mode it continuously defragment your selected disk drives in the background.


From the description of the homepage, the "Set-it-and-forget-it"-mode is just like with O&O Defrag: It schedules a complete defrag and if the disk is heavy fragmented each time, it schedules the next run a bit sooner. If there is almost no fragmentation upon a run, the time to the next run gets bigger.

mst Defrag defragments your computer "pro-actively" which means, it monitors file writes and after some program has written a file, mst Defrag uses the next opportunity with low cpu usage to defragment this very file, not the whole disk. So you will have a fully defragmented disk after about 5 minutes after the last file write operation.

Try it and compare. :-)

Cheers,
-mARKUS

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Think about it: if you defragment single files, it means relocating it into a large empty block. After a while there will be no more large enough contiguous space, so you have to move many files to make room. Pro-activity means nothing, it is just a slogan. Every on-line defragmenter collects and updates fragmentation data continuously, and schedules the work in the background as necessary. None of them starts the file system analysis afresh at each call.

Comparing the results is difficult. Diskeeper was not the best in the c't Magazin's comparison, with its default settings, that is, when it was the least obtrusive. Periodically you can perform full defragmentation, with relocating directories together, moving large, often used program files to the fastest part of the disk, and only then you rely on the background activity. Of course, the set-it-and-forget-it mode does not schedule full defragmenting, but works constantly with very low priority, and keeps the file system reasonably un-fragmented at all the times. I can only tell that Diskeeper is good enough and I generally dislike products with misleading advertisements, like mst Defrag. It might be a fine product, but then why not be honest in advertising?

mbirth
  • Members
  • 40 posts
  • Last active: Jul 31 2008 11:12 AM
  • Joined: 03 Oct 2005

Every on-line defragmenter collects and updates fragmentation data continuously, and schedules the work in the background as necessary. None of them starts the file system analysis afresh at each call.


I tested O&O Defrag about a year ago and it definately does nothing in background but waiting for the dynamic timespan until the next run.

Also the homepage from Diskeeper tells that the defragmentation runs will be scheduled dynamically depending on the fragmentation. There's nothing told about constant monitoring of the filesystem. Also the "Set-It-And-Forget-It"-technique is nowhere explained. I just found "SmartScheduling mode automatically schedules background defragmentation according to your individual usage patterns" which is the thing I know from O&O. And from the FAQs at Diskeeper's homepage, there's always written about "Set-it-and-forget-it-scheduling". So again no point to something like background monitoring. If this feature provides background monitoring, why don't they announce it on their homepage?

On the mst Defrag homepage, you can read "The background mode is characterized by a constant monitoring of drives for changed data. When a new or changed file is detected, it is inserted in a list of files to check. If the computer is not under heavy user load or if other factors seem opportune, the files on the FTC list will be analysed and, if needed, defragmented. This mechanism ensures that a fragmented file will be in an optimal state at the latest of 5 minutes." which is exactly what they mean with "pro-active".

Also there are/were concernc about spyware being contained within Diskeeper (because the CEO of Executive Software is a confessing Scientologist). There's a German page about it here. But I guess this turned out to be unfounded.


So after reading the homepage of Diskeeper with all its buzz-words which turn out to be the same thing other products have built-in for years, I still think mst Defrag's pro-activity is a unique feature.

Oh, and mst Defrag uses your computer's idle time to re-arrange files so that the gaps get closed, if neccessary. Just to mention it.


Cheers,
-mARKUS

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

…background monitoring, why don't they announce it on their homepage?

I think it is a technical detail most users don't care about. The do say

"Set It and Forget It" operation - defragments undetectably in the background

This is what matters, and it is the same as

us[ing] your computer's idle time to re-arrange files so that the gaps get closed, if neccessary. Just to mention it.

the same thing other products have built-in for years

I don't know who was the first, but Diskeeper has been offering it for several years. Just because you saw it first somewhere else does not mean they invented the background defragmentation.

Also there are/were concerns about spyware being contained within Diskeeper (because the CEO of Executive Software is a confessing Scientologist).

Are you saying, that being a Scientologist is a crime? Or it predestines them to commit crimes? Alone your word "confessing" indicates that you think it is a crime, what he confesses. You may or may not agree with their philosophy or religion or daily practices, but calling them criminals is an insult. You may boycott their products, it is you right. There are people who don't buy Microsoft products. Others don't go to shops owned by a Jew. Or an African American. Or a Turk. It only says something about you, not about Diskeeper.

Decarlo110
  • Members
  • 303 posts
  • Last active: Feb 12 2006 02:15 AM
  • Joined: 15 Dec 2004

Alone your word "confessing" indicates that you think it is a crime, what he confesses.

from TheSage Dictionary freeware:

confess (verb)
1. Admit, make a clean breast of.
2. Confess to God in the presence of a priest, as in the Catholic faith.
3. Confess to a punishable or reprehensible deed, usually under pressure.

confession (noun)
1. (Roman Catholic Church) The act of a penitent disclosing his sinfulness before a priest in the sacrament of penance in the hope of absolution.
2. A written document acknowledging an offense and signed by the guilty party.
3. A document that spells out the belief system of a given church (especially the Reformation churches of the 16th century).
4. A public declaration of your faith.
5. An admission of misdeeds or faults.

Note the similarity:

profess (verb)
1. State insincerely.
2. Confess one's faith in, or allegiance to.
3. Admit, make a clean breast of.
4. Practice as a profession, teach, or claim to be knowledgeable about.
5. Take vows, as in religious order.
6. Receive into a religious order or congregation.
7. State freely.

One of the few things i like about lawyers is meticulousness in the skill of interpretation and formal argument.
1) The Open Source Definition http://www.opensourc...ition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <>

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
What is your point, Decarlo? According to the dictionary, the gerund from the verb "confess" means admitting a punishable or reprehensible deed (the other two meanings do not fit). Do you think it was used mistakenly in place of professing? I don't. It appears in the same sentence as "spyware", which clearly indicates a criminal act.

Decarlo110
  • Members
  • 303 posts
  • Last active: Feb 12 2006 02:15 AM
  • Joined: 15 Dec 2004

Also there are/were concernc about spyware being contained within Diskeeper (because the CEO of Executive Software is a confessing Scientologist).

It appears in the same sentence as "spyware", which clearly indicates a criminal act.

Consider the following statements, as examples:
1. The CEO has more than once made a public confession of his Scientology beliefs.
The above statement does not necessarily carry a negative connotation, but can simply be an acknowledgment that he did.
2. The CEO is a confessing Scientologist, and was convicted of a crime.
This example clearly associates a negative aspect; however, even still it may only be to only this person and not necessarily to the whole of Scientology.
3. The CEO is a confessing Scientologist, and we are proud to have hosted his business seminar.
Nothing negative intended here.
4. The CEO is one of our fellow confessing Scientologists.

So we see that using the term does not automatically convey a negative connotation. In fact, in some Christian circles the term "confessing" is used alternatively/synonymously with "professing", so that may be what happened here also.

It appears in the same sentence as "spyware", which clearly indicates a criminal act.

Spyware may be a criminal act to you, and i would agree with you on that. However, i do not know if it is public record whether Scientology has promoted the use of spyware as what it thinks is legitimate means for what it considers a good, legitimate purpose. It may be that Scientology has publicly said that spyware is not always a bad thing. I have not ruled this out. So if this is the case, then what is being said may simply be a recognition of official Scientology policy, rather than marking the entire group as criminals. Sharp disagreement on one point does not necessarily constitute negative labeling of the whole group as criminals. There are finely nuanced areas in law where there can be sharp disagreement on one particular point, yet this is not enough to as a whole change characterization of a group or act significantly.
1) The Open Source Definition http://www.opensourc...ition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <>

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Let mbirth tell what he meant. I understood the sentence saying that because Diskeeper is linked to Scientology, there are concerns about spyware. And it means to me, that Scientology is accused to do bad things. - But let's move any further discussions about it to the general chat area.

mbirth
  • Members
  • 40 posts
  • Last active: Jul 31 2008 11:12 AM
  • Joined: 03 Oct 2005
I just wanted to sum up the contents of that German page. There, you can also read about Executive Software refusing technical support to a pharmaceutical company just because they didn't like the company (to be exactly: Scientology doesn't like Ritalin, the company did produce Ritalin and so Executive Software refused support).

Also, just to mention it, I'm German and so I don't know every single subtlety of the English language. And I'm not against ANY religion. But you feeling *THIS* offended by my ambiguous sentence could mean you're a member of Scientology, too, which could then explain why you prefer Diskeeper against some IMHO better solutions. Just some thoughts... don't get offended again.

And to come back to the original topic: Tell me any sentence from the Diskeeper homepage, where there is told WHAT Diskeeper does in the background. I only read "... is running in background" which can mean anything from "waiting for next run" up to "doing useful things".

I don't like companies that tell you something about their soft but also tell you nothing.

But, well, as a matter of fact, you are allowed to use whatever piece of software you want. I just wanted to tell you an alternative.

Cheers,
-mARKUS