Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1898
  • Last Modified:

Defragmentation over Network??

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
agbor1960
Asked:
agbor1960
  • 7
  • 6
  • 4
  • +4
2 Solutions
 
DexstarCommented:
@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
 
ShineOnCommented:
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
 
DexstarCommented:
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
ShineOnCommented:
AAaaaacccchhh, I should know better!

ShineOn

0
 
ShineOnCommented:
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
 
The--CaptainCommented:
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
 
agbor1960Author Commented:
Is script my only possibility??? is there any GPO doing the job???
0
 
ShineOnCommented:
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
 
ShineOnCommented:
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
 
chicagoanCommented:
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
 
ShineOnCommented:
hehe.

Seriously, tho - what's PE in this context...?
0
 
chicagoanCommented:
Page Editor - an EE volunteer who facilitates things
0
 
jadedataMS Access Systems CreatorCommented:
0
 
DexstarCommented:
@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
 
chicagoanCommented:
0
 
DexstarCommented:
@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
 
chicagoanCommented:
let me hunt for one in quickbasic...
0
 
kiranghagCommented:
but i dont think there is a "defrag.exe" on a windows machine anymore...
so third-party utilities are the only solutions.
0
 
chicagoanCommented:
on 2000 it's dfrgntfs.exe, but a defrag.exe command line was added to XP and 2003
0
 
kiranghagCommented:
i ran dfrgntfs.exe,
it gives me a messagebox "commmand line operation of defrag is not supported."
0
 
chicagoanCommented:
you are correct, hence the question
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 7
  • 6
  • 4
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now