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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DeFrag Question How to reach 200!

Status
Not open for further replies.

Ravenrx7

IS-IT--Management
Aug 21, 2002
109
0
0
US
It's a simple question, we have a 2003 server running AD with 200 clients (XP clients), what method should be used to run a remote defrag service on all the 200 clients?
I've looked at VB and batch so far.

thanks for any advice

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
I didn’t find anything that would setup defrag’s to run on client workstations via AD without a script or program of some kind. Below are some links that prove helpful though.

Several ideas on one page with examples:
This link has some MS info:
Third party applicaton:
nedrudrelyt = tyler durden
 
this is what i found on the net, its a VB script which will kick off the defrag automatically. What i did was, create an AT cmd to run this program every other day and i'll use out the script using AD. But in order to run this program using this script you have to have admin rights, so my next question is, is there a way to put into the script to logon as an admin before running. the script is below:

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

'This process requires the user to have administrative rights, and I'm still looking for
'a way to run this process in the background. If you schedule it to run via Scheduled
'Tasks, no user interface comes up and so the keystrokes don't get processed...

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"
wscript.sleep 1000

if WshShell.AppActivate("Defragmentation Complete") = TRUE then
' no way it's already defragged! must be a utility partition!
'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 a tab key to move the focus from View Report button to the Close Button
WshShell.Sendkeys "{TAB}"
Wscript.Sleep 500

'Send a DOWN key to arrow down to C: (hopefully)
WshShell.SendKeys "{DOWN}"
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"
wscript.sleep 1000

end if

'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}"

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
I got it to work, using a .bat file which will run the .vbs script m-w-f @ 10:40

at /del /YES
at 10:40pm /every:M,W,F \\XXXXXX\NETLOGON\defrag.vbs


Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
This in a bat file will work it will schedule the job to run under system every monday.

AT \\computer1 12:35 /Every:M c:\windows\system32\defrag.exe c:
AT \\computer2 12:35 /Every:M c:\windows\system32\defrag.exe c:
AT \\computer3 12:35 /Every:M c:\windows\system32\defrag.exe c:
 
this might be a stupid question, but on the last two methods to defrag the remote pc, does the user have to logged on? most of these pc are left at the log on screen.

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
No it will run when logged off in the background, it also runs in the background even if the user is logged on.
 
i'll have to try your method, if you run an AT cmd to kick off that Vb script, it doesn't work

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
It's possible that the account that AT commands run under which is system by default can't access the location of the VB script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top