Consulting

Results 1 to 16 of 16

Thread: run a looping defragmentation

  1. #1

    Red face run a looping defragmentation

    I'd like to know if anyone knows if, using VBA, a routine can be made that

    first
    opens dfrgntfs.exe (Windows defragmenter)

    then
    picks a drive (it has to do this because I have multiple partitions)

    then with a for next loop
    defragments the drive

    THEN
    receives a message that defragmentation is complete and then restarts defragmentation. This would be very useful when multiple runs are necessary to eliminate all of the red part of the defrag graph.


    - Edward
    Below is my really outdated website, but someday I'll get back to working on it
    http://www.edwardtisdale.com

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi there,

    While this is sort of possible using VBA, I'm not sure why you would do it.
    Effectively, however you do this, you will need to run defrag.exe from a command line ("dfrgntfs.exe" is the win32 app and doesn't run from a command line).
    You can see the syntax for the arguments (which drive and some other options) by typing defrag at a command prompt.

    To run defrag in the background with vba you'd use[VBA]Const strCmdLine As String = "your path to defrag.exe and arguments"
    Shell strCmdLine, vbHide[/VBA] but I think controlling multiple passes and different drives consecutively will be a PITA

    Is there any reason you can't run scheduled defrags via the control panel?
    K :-)

  3. #3

    Thanks I'll give that a try

    As far as running scheduled defrags, I might try that with defrag.exe as well as trying your code. Going through Scheduled Tasks in System Tools (Win2k Pro) doesn't allow me to schedule a defrag otherwise. Thanks for the help. Is that what you meant by the Control Panel? I know when I had win98 I could do that, or maybe it was on WinNT4.0wks.


    Also, I'm new here; what is PITA? Something bad I can guess.

  4. #4
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Pain in the [insert appropriate body part]

  5. #5
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi Edward,

    I find the windows defrag won't work if you're trying to do something, it tends to restart over and over. Not only that, it's really slow and doesn't do a very good job of defragmenting at all...

    Try Diskeeper (30 day free trial - then pay. Alt: see if you can find a download for the free Diskeeper Lite). Diskeeper will defrag in the background and you can schedule it to run when there's a period (choose your own period) of inactivity.

    There's other defrags out there, but in my experience the inbuilt windows one is the worst of them all

    Regards,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  6. #6

    Thanks I'll look for diskeeper lite

    Quote Originally Posted by johnske
    Hi Edward,

    I find the windows defrag won't work if you're trying to do something, it tends to restart over and over. Not only that, it's really slow and doesn't do a very good job of defragmenting at all...

    Try Diskeeper (30 day free trial - then pay. Alt: see if you can find a download for the free Diskeeper Lite). Diskeeper will defrag in the background and you can schedule it to run when there's a period (choose your own period) of inactivity.

    There's other defrags out there, but in my experience the inbuilt windows one is the worst of them all

    Regards,
    John
    Thanks I'll look for diskeeper lite

  7. #7

    Lightbulb re:multiple passes and different drives

    Quote Originally Posted by Killian
    but I think controlling multiple passes and different drives consecutively will be a PITA
    Yeah, I don't necessarily want to do it with multiple drives, just the same one over and over.

  8. #8
    VBAX Regular PC509's Avatar
    Joined
    Sep 2004
    Location
    Boardman, OR
    Posts
    8
    Location
    You might also look into O&O Defrag Professional. It seems to do a very good job defragging, and has some advanced options that help out a lot. System files usually can't be defraged, but you can run a "boottime frag" which defrags the entire drive including the system files. This can help with actual OS speeds, as well.

    Download : http://www.majorgeeks.com/download809.html
    Info : http://www.majorgeeks.com/download809.html

    Good luck!

  9. #9

    Cool thanks

    yeah I might try that. It would be convenient to do this just for myself, but more than that I would just like to see how I can use VBA to do some kind of task with an application other than what is in Microsoft Office. I have VB6.0 LE only (for VB; for other languages I have VC5.0, JDK,Activeperl,...) I'll see how it works. The Diskeeper Lite was kinda cool to look at but not really what I wanted. I would like to see the on boot system file defrag though, that sounds interesting.

  10. #10
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by johnske
    Hi Edward,

    I find the windows defrag won't work if you're trying to do something, it tends to restart over and over. Not only that, it's really slow and doesn't do a very good job of defragmenting at all...

    Try Diskeeper (30 day free trial - then pay. Alt: see if you can find a download for the free Diskeeper Lite). Diskeeper will defrag in the background and you can schedule it to run when there's a period (choose your own period) of inactivity.

    There's other defrags out there, but in my experience the inbuilt windows one is the worst of them all

    Regards,
    John
    Perfect Disk is much better than Diskkeeper.
    Read the stuff at http://www.perfectdisk.com/products/...tdisk2k/wp.cfm.

  11. #11
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by PC509
    You might also look into O&O Defrag Professional. It seems to do a very good job defragging, and has some advanced options that help out a lot. System files usually can't be defraged, but you can run a "boottime frag" which defrags the entire drive including the system files. This can help with actual OS speeds, as well.

    Download : http://www.majorgeeks.com/download809.html
    Info : http://www.majorgeeks.com/download809.html

    Good luck!
    Perfect Disk is better than O & O Defrag.

  12. #12
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by johnske
    Hi Edward,

    I find the windows defrag won't work if you're trying to do something, it tends to restart over and over. Not only that, it's really slow and doesn't do a very good job of defragmenting at all...

    Try Diskeeper (30 day free trial - then pay. Alt: see if you can find a download for the free Diskeeper Lite). Diskeeper will defrag in the background and you can schedule it to run when there's a period (choose your own period) of inactivity.

    There's other defrags out there, but in my experience the inbuilt windows one is the worst of them all

    Regards,
    John
    Fergot to mention, background defragging is an awful idea and should never be used.

    Indeed, Perfect Disk was wise enough to not even include such a silly option.

    Perfect Disk has a tool that will do a background Trend Analysis.
    Using that info, you can decide when and how often to defrag particular drives. Raxco also provides an Access database with built-in queries that can be hooked to the Trend Analysis.

  13. #13
    VBAX Regular PC509's Avatar
    Joined
    Sep 2004
    Location
    Boardman, OR
    Posts
    8
    Location
    Quote Originally Posted by Howard Kaikow
    Fergot to mention, background defragging is an awful idea and should never be used.

    Indeed, Perfect Disk was wise enough to not even include such a silly option.

    Perfect Disk has a tool that will do a background Trend Analysis.
    Using that info, you can decide when and how often to defrag particular drives. Raxco also provides an Access database with built-in queries that can be hooked to the Trend Analysis.
    Alright, let's see your business card, Mr. President of Perfect Disk...!

    I'm looking into PD as I type. It looks pretty good. I might give it a try. Always nice to find a new piece of software and give it a go! Thanks!

    My first response to your posts were going to be: Why is it better?! But, that last one did go into more detail. Thanks!

  14. #14
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by PC509
    Alright, let's see your business card, Mr. President of Perfect Disk...!

    I'm looking into PD as I type. It looks pretty good. I might give it a try. Always nice to find a new piece of software and give it a go! Thanks!

    My first response to your posts were going to be: Why is it better?! But, that last one did go into more detail. Thanks!
    As of few daze ago, the best price was at amazon.

    Note that the raxco web site has a price search that gives the lowest prices, but, there's my big butt again, one should visit each vendors web site to see if there's also a rebate.

    I got lucky and purchased when there was a $20 rebate, if purchased from amazon, but that expired last month.

    However. amazon still has a far lower-price, I know knot y.

  15. #15

    PD

    Yeah The O&O is impressive. I'll do a search for the PD when I get a chance. thanks everyone.

  16. #16
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by EdCompSci
    Yeah The O&O is impressive. I'll do a search for the PD when I get a chance. thanks everyone.
    PD is better. See http://www.perfectdisk.com/products/...tdisk2k/wp.cfm.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •