Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Scheudle a Defrag, 2k Pro

Options
  • 31-07-2003 2:56pm
    #1
    Registered Users Posts: 6,949 ✭✭✭


    whats the best way to do this?

    The task scheduler with the OS will launch defrag, but I need to specify some partitions to be defragged once a week.


Comments

  • Closed Accounts Posts: 119 ✭✭retneil


    VBScript initialised by AT at command line:

    VBS :

    http://www.c0detw1ster.com/Scripting%20Tips/Scripting%20Articles/Defrag(vbs).htm


  • Registered Users Posts: 6,949 ✭✭✭SouperComputer


    huh?


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,761 Mod ✭✭✭✭Capt'n Midnight


    set schedule service to autostart
    AT 18:00 /interactive /every:m,t,w,th,f,s,su defrag.exe c: -f -v

    interactive allows you to see what is going - not a background process - can also start this on a remote PC too..

    You can also use net view > netview.txt
    and then use FOR /F (delims =\ "etc..)
    to parse the file to start defrag running on all PC's on the LAN

    If you have NT then use the contig & pagedfrg utils on www.sysinternals.com to make your files contiguous.
    contig c:\*.* -s -v
    Note: if you have NTFS compression then contig can be painfully slow.

    (going from memory so double check the syntax)


  • Registered Users Posts: 6,949 ✭✭✭SouperComputer


    theres no defrag.exe on 2k that i can see :(

    theres a dfrg.mmc alright, ill try the switches on that and see what happens.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,761 Mod ✭✭✭✭Capt'n Midnight


    Check the i386 folder for debug.ex?


  • Advertisement
  • Closed Accounts Posts: 132 ✭✭marrakesh


    huh ?>

    doh should have explained myself better.

    Defrag cannot be scheduled in 2k u need to use a workaround. Normally there are defrag programs that can be scheduled on the market but they cost $$$ for win2k. So an easier solution is to get the vbs scipt listed above copy to system then schedule a task to run the script. The script shall click the defrag buttons by first launching defrag and then using the hotkeys to press defrag. Its a bit of a strange one but ms didnt want defrags to be allowed to be scheduled under 2k therefore everyone goes to the third party vendor and buys there package. I would assume like a lot of ms stuff that defrag is in fact not theirs but licensed off a third party vendor who stated to ms not to allow defrags to be scheduled therefore forcing customers to buy there application.

    drop a line bakc if you have any queries. AT is to set the scheduled task to run at interactive level...

    drop a line back if u have any questions.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,761 Mod ✭✭✭✭Capt'n Midnight


    D:\>defrag.exe
    Windows Disk Defragmenter
    Copyright (c) 2001 Microsoft Corp. and Executive Software International, Inc.
    Usage:
    defrag.exe <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


  • Closed Accounts Posts: 132 ✭✭marrakesh


    There is no defrag.exe on windows 2000.


  • Registered Users Posts: 1,237 ✭✭✭GUI


    im gonna 3rd that
    There is no defrag.exe on windows 2000.

    Microsoft Windows 2000 [Version 5.00.2195]
    (C) Copyright 1985-2000 Microsoft Corp.

    D:\>defrag
    'defrag' is not recognized as an internal or external command,
    operable program or batch file.

    D:\>


  • Registered Users Posts: 6,949 ✭✭✭SouperComputer


    marrkesh,

    its the link I have the problem with!! I tried a couple of combinations but no joy :(


  • Advertisement
  • Closed Accounts Posts: 132 ✭✭marrakesh


    throw it into a vbs script fairly explanatory
    Dim NumDrives, FSO, Drives, Count
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set Drives = FSO.Drives
    NumDrives = Drives.Count
    NumDrives = NumDrives - NumDrives

    Const DriveTypeFixed = 2
    Const DriveTypeNetwork = 3

    For Each Drive in Drives
    If Drive.DriveType = DriveTypeFixed then NumDrives = NumDrives + 1
    Next

    Set Drives = Nothing
    Set FSO = Nothing

    set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "dfrg.msc"
    WScript.Sleep 2000
    While WshShell.AppActivate("Disk Defragmenter") = FALSE
    wscript.sleep 1000
    WshShell.AppActivate "Disk Defragmenter"
    Wend

    do while (Count <= NumDrives)

    wscript.sleep 200
    WshShell.SendKeys "%A"
    wscript.sleep 200
    WshShell.SendKeys "D"

    While WshShell.AppActivate("Defragmentation Complete") = FALSE
    wscript.sleep 5000
    Wend

    WshShell.AppActivate "Defragmentation Complete"
    wscript.sleep 200
    WshShell.Sendkeys "{RIGHT}"
    wscript.sleep 200
    WshShell.SendKeys "{ENTER}"
    wscript.sleep 500
    WshShell.Sendkeys "{DOWN}"

    Count = Count + 1

    loop

    WshShell.Sendkeys "%{F4}"


  • Registered Users Posts: 6,949 ✭✭✭SouperComputer


    cool, worked a treat, cheers!


  • Registered Users Posts: 6,949 ✭✭✭SouperComputer


    hmm, okay, I have 2 partitions that are mounted in folders. How can I change the script to defrag them. It seems to defrag the c: drive only.


  • Closed Accounts Posts: 132 ✭✭marrakesh


    Make 2 scripts and send a tab key and the use WshShell.Sendkeys "{DOWN}" to select the D:\ drive.. Should work fine then...


Advertisement