Solved

Defragmentation over Network??

Posted on 2003-11-20
22
1,886 Views
Last Modified: 2012-08-14
Hello experts...

Could anyone help answer this question please..is it possible to defragment C drives or i mean local drives over the network
without spending any $$$$ ..???

Cheers and Thanks
0
Comment
Question by:agbor1960
  • 7
  • 6
  • 4
  • +4
22 Comments
 
LVL 19

Assisted Solution

by:Dexstar
Dexstar earned 300 total points
ID: 9790791
@agbor1960:

> Could anyone help answer this question please..is it possible to defragment
> C drives or i mean local drives over the network without spending any $$$$ ..???

You can use a script to defrag the drives, and then schedule that script to run on each computer, over the network.
I got the code from http://www.winntmag.com/Articles/Index.cfm?ArticleID=8276.  Just copy that to a .VBS file, and schedule that to run on whichever computers you want.

Hope That Helps,
Dex*


'This script launches defrag and sends keys to the UI in order to automate the defrag
'process.

set WshShell = CreateObject("WScript.Shell")

'Launch Defrag from the command line and wait for a second
WshShell.Run "dfrg.msc"
WScript.Sleep 1000

'Wait until the application has loaded - Check every second
While WshShell.AppActivate("Disk Defragmenter") = FALSE
      wscript.sleep 1000
Wend

'Bring the application to the foreground
WshShell.AppActivate "Disk Defragmenter"
WScript.Sleep 200

'Send an ALT-A key to bring down the degrag menu
WshShell.SendKeys "%A"
WScript.Sleep 200

'Send a D to start the defrag
WshShell.SendKeys "D"

'Wait until the defrag is completed - Check for window every 5 seconds
While WshShell.AppActivate("Defragmentation Complete") = FALSE
      wscript.sleep 5000
Wend

'Bring the msgbox to the foreground
WshShell.AppActivate "Defragmentation Complete"
WScript.Sleep 200

'Send a tab key to move the focus from View Report button to the Close Button
WshShell.Sendkeys "{TAB}"
Wscript.Sleep 500

'Send key to Close the Defragmentation Complete window
WshShell.Sendkeys "{ENTER}"
Wscript.Sleep 500

'Send and ALT-F4 to Close the Defrag program
WshShell.Sendkeys "%{F4}"
0
 
LVL 35

Expert Comment

by:ShineOn
ID: 9791086
It depends on your OS version (assuming it is a Windows version.)

This kind of task can be scheduled remotely using the Win2K/WinXP remote scheduling features, which I believe are controlled through a policy.  I haven't done it myself, but someone here must have...;^)  I don't know that it's necessary to set up a script.

Kick me if I'm all wet... ;)
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9791266
Well, it SHOULDN'T be necessary to set up a script, but it is.  When Microsoft licensed the defrag tool, they crippled it so that it can't be run from a remote computer, so the original company can still sell their "server" version.  The users got totally screwed on that one.

But, that script automates the mouse clicks necessary to launch the program and run it, so it gets around their little ploy...

Dex*
0
 
LVL 35

Expert Comment

by:ShineOn
ID: 9791313
AAaaaacccchhh, I should know better!

ShineOn

0
 
LVL 18

Expert Comment

by:chicagoan
ID: 9792583
0
 
LVL 35

Expert Comment

by:ShineOn
ID: 9794722
Also, from http://beta.experts-exchange.com/Networking/Q_20676037.html

----------------------------------------------------------------------------------------------------------------------
Accepted Answer from ekspurt
Date: 07/12/2003 09:33AM CDT
 Accepted Answer  

This article does specify that dfrgntfs.exe and dfrgfat.exe cannot be scheduled, as expressed by kiranghag (thanks for the reminder).
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q227463

But there is a work-around.  My apologies, I had gotten a utility from the article below a few months ago, set the filename to defrag.vbs, and that's why I referred to it as such above.

Article describing how to schedule a Win2K defragmentation.
http://www.winntmag.com/Articles/Index.cfm?ArticleID=8276

VB script code for this article (available through the article's  "Download the Code" link):
http://www.winnetmag.com/Files/8276/8276.zip

Cheers!
-------------------------------------------------------------------------------------------------------------------------------------------

I stand corrected, and humbly bow out...
0
 
LVL 16

Expert Comment

by:The--Captain
ID: 9795596
Anything that allows automation of a remote windows GUI should do the job. Sounds like ShineOn has provided his usual swath of URLs that should cover this.

ShineOn - As an EE Networking PE, would it be too much to ask for me to bug you about certain topics from time to time that might require some references from your obviously huge list of handy URLs?  If so, don't worry about posting your email address - netminder will share it with me if I reference a post from you where you indicate this is OK.

Cheers,
-Jon
0
 

Author Comment

by:agbor1960
ID: 9795771
Is script my only possibility??? is there any GPO doing the job???
0
 
LVL 35

Expert Comment

by:ShineOn
ID: 9796226
The--Captain -

You can ask me or bug me as much as you want...

Believe it or not, my list of handy URLs is because I know how Google and other search engines work, and can get what I'm looking for quickly.

I hate to give away my trade secrets, but being able to use the tools is part of being a good troubleshooter...

I guess I just know where to look, and how to ask the question, which gives me a bit of an edge in some instances.

0
 
LVL 35

Expert Comment

by:ShineOn
ID: 9796256
To: The--Captain -

PE stands for something other than Physical Education in this venue...  What is a PE, if I may expose my ignorance?

(One of the things I've learned over the years is to ask questions that benefit not only myself, but others paying attention at the time the question is asked...)
0
 
LVL 18

Expert Comment

by:chicagoan
ID: 9796370
isn't there a command line switch now?
c:\windows\defrag.exe c: /noprompt /q

 Networking PE

That's where each machine gets it's own Network Engineer (Personal Edition)
(usually found in Micro$oft environments)

;-)
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 35

Expert Comment

by:ShineOn
ID: 9796613
hehe.

Seriously, tho - what's PE in this context...?
0
 
LVL 18

Expert Comment

by:chicagoan
ID: 9797020
Page Editor - an EE volunteer who facilitates things
0
 
LVL 32

Expert Comment

by:jadedata
ID: 9797951
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9798155
@agbor1960:

I checked and chicagoan is right about there being a command line version for XP, but not for W2K.  So, the answer really depends on which you are using.

If you are using XP:
Like Chicagoan said:  There is a command line utilitity you can run.  You can even run it remotely.  Download this free utility:  http://www.sysinternals.com/ntw2k/freeware/psexec.shtml and then you can Defrag any XP machine on your network like this:
   1) Start -> Run
   2) psexec \\COMPUTERNAME defrag

If you are using W2K:
You'll need to use the script that I told you before in my original response.  But you can still copy that script to a remote computer, and then invoke it using the PsExec tool like I said before.

Dex*
0
 
LVL 18

Accepted Solution

by:
chicagoan earned 200 total points
ID: 9798266
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9798294
@chicagoan:  I looked at the source code for that utility, and it basically does the EXACT same thing that the script does, except it does it in C++.  The code is much bigger because it has to have code to send the right key messages to the right window to make it work, but the scripting host has an object that does that for you, so the code is much more simple.  Isn't that interesting?

Dex*
0
 
LVL 18

Expert Comment

by:chicagoan
ID: 9798361
let me hunt for one in quickbasic...
0
 
LVL 10

Expert Comment

by:kiranghag
ID: 9801479
but i dont think there is a "defrag.exe" on a windows machine anymore...
so third-party utilities are the only solutions.
0
 
LVL 18

Expert Comment

by:chicagoan
ID: 9802727
on 2000 it's dfrgntfs.exe, but a defrag.exe command line was added to XP and 2003
0
 
LVL 10

Expert Comment

by:kiranghag
ID: 9808269
i ran dfrgntfs.exe,
it gives me a messagebox "commmand line operation of defrag is not supported."
0
 
LVL 18

Expert Comment

by:chicagoan
ID: 9808331
you are correct, hence the question
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now