rory 0 Posted January 4, 2007 Okay this is a small thing i came up with over the past few nights .. I have labeled it as BETA as it has not been fully tested for any considerable length of time. I hope that others can test it for me, and send feedback, or post here. It is free either way and will stay that way. Basically I was looking for a way to add Defragmenting to my Tweak Software (not implemented yet), and found out we can do this using the built in Command Line "Defrag.exe" program that comes with Windows XP. Using some examples I found in VBScript I converted it, placed in in a VB Exe, and added some additional features. Whether this is useful for a PC DVR is yet to be determined, or up to the user, but it should work well for a home PC at the least. What is Defragmenting? Speeds up access to data on your hard disk drives. It reduces the amount of fragmentation in file systems by physically reorganizing the contents of the disk in order to store the pieces of each file close together and in order (contiguously). Click here for more details What this program does: Runs from anywhere You can place this program on a Jump drive and just run it from there. No installation is required, however currently it requires Windows XP. Defrags all hard disk drives This includes all physical drives Create's a Text Report which tracks results/errors Report is created as monthly files (stored in %windir%) Errors are tracked also inside this report file. To view the report, either manually open up the program, and if there is a report available for the current month, the "Report" button will be enabled; click on that; or goto the windows folder and look for "DefragReport012007.txt", where 012007 is the month and year. Allows Switches to be passed to the program Switches allow auto start, auto end, & removal of drives from the defrag. See below for more details. Program is named Defrag.exe for easy identification The Program closes the built in Windows XP Command line defrag.exe program when it is completed or manually stopped, using unique identification so it closes the correct program, and not itself. This is required so the program does not hang when prematurely terminated. Also the FAT32 and NTFS Windows Defrag programs which run in the background, are closed as well. SWITCHES To add a switch, first save the file somewhere it cannot be deleted by accident, such as in its own folder. Create a shortcut of the file then open that shortcut's properties. Add one of the following switches after the "Target" path. You could then just drag that Shortcut to the Start Up section on the Programs Menu, or add it to Task Scheduling (see below). Put a space inbetween each one when using multiple switches. Switches are not case sensitive. Auto Start = -s Starts the program minimized and runs the defrag Auto End = -e Will end the program after defrag, if it is minimized Maximize if Minimized = -m When defrag is completed program will pop up, if minimized. if Auto End is selected with the -m switch, it will not Auto End. Remove Drives = /r:C Where C is the letter of the drive which you do not want to defrag Multiple Drives can be removed, eg. /r:CDE SCHEDULING To create a schedule for the defrag, goto Control Panel, Scheduled Tasks. Click on "Add Scheduled Task". Browse for this Defrag.exe program file (where you saved or placed the file). Name the Task or leave as is. Select the type of the schedule; an example would be "Weekly". Select a "Time" and "Day" of the week to perform this task. If you need to enter a specific user to run the program, enter that information, otherwise leave it as default. Check "Open Advanced Properties" and Click the "Finish" button. When the task properties opens, enter required switches in the "Run" box, after the program path. Check the box that says "Run only if logged in". Click "Apply" and "Ok" to exit.To test the Scheduled task, right click on the task and click "run". If it works then all is set properly. "Run" example for auto run, auto end, and removal of the C drive: D:\Defrag\Defrag.exe -s -e /r:c REQUIREMENTS Windows XP (may work with 2000, ME, and 98, once defrag.exe is located in the System folder). Currently requires Scripting enabled/allowed (this will change). Download (96Kb) http://www.bahamassecurity.com/uploads/Defrag.exe Here is a version that will Auto Start and End without using switches http://www.bahamassecurity.com/uploads/DefragAuto.exe .. Share this post Link to post Share on other sites