Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto defragment 1

Status
Not open for further replies.

HKNinja

MIS
Nov 17, 2002
148
US
hi all,

I'm trying to find a solution on auto defragging all the workstations in my office. According to Microsoft's website, you need to run defragment manually with Admin rights. However, at one time, my girlfriend told her her company's MIS dept is going to run an overall defragment on all the workstations (probably a few hundred of them) and asked them to just leave the computer on (logged out) and the defragment took place overnight. Can anybody give me clue as how this can be done? Thanks!

- HKNinja
A+, MCP
 
Thanks Mark,

That looks good. But I'm wondering if there if I can use group policy to control defreg instead of just scheduling it...

-Harry
A+, MCP
 
Not that I know of. Keep in mind you dont need to install third party software to do this. You can schedule the command line version of the defragger to run.

defrag
Windows Disk Defragmenter
Copyright (c) 2001 Microsoft Corp. and Executive Software International, Inc.
Usage:
defrag <volume> [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text
 
Mlichstein,

I believe you can only schedule with WinXP as this was an agreement with Executive when MS went from the Symantec version of Defrag tot he DiskKeeper Lite version.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
This is very helpful, Mark.
I tested the software and it works wonderfully. Even better, it's free! The only down side is I've to manually copy this file into each of the workstation and schedule it.
One question, will the task be executed if user is not login?

- Harry
A+, MCP
 
Yes, the task will run if a user is not logged on, in fact that would be preferred so that as few files are in use as possible.

There is no need for you to manually copy the file over to each workstation. You can script this to get it done in a few minutes.

Create a text file called WSLIST.TXT. Populate WSLIST with the names of each workstation you need the file on. One machine name per line. Save the WSLIST file and the following script in the same directory, give the script a .VBS extension. Also put AutoDefrag.exe in the same directory. Then double click it to have it copy the file over to each workstation for you.

'==========================================================================
'
' VBScript Source File --
'
' NAME: CopyAutoDefrag.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL : ' DATE : 03/29/2002
'
' COMMENT: <Copies AutoDefrag to a list of workstations>
'
'==========================================================================
On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close

For Each strWorkstation In RemotePC
'Do something useful with strWorkstation

If Not oFSO.FileExists("\\"&strWorkstation&"\c$\Winnt\AutoDefrag.exe") Then
Call WSHShell.Run("cmd.exe /C copy Autodefrag.exe \\" & strWorkstation & "\c$\Winnt")
End If
wscript.sleep 200

Next

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Just as you can easily script the copy of the file to the workstations, you can also script the setup of the scheduled task to each of the machines.

Take a look at the AT command syntax and you should be able to figure it out using most of the code above. You basically would just need to alter the Run command to create the process on the Remote computers which is supported by AT.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
This is very userful, Mark. The VB script is great and it get the jobs done in seconds. Thanks a lot!
 
Glad you found it helpful HKNinja.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top