Analyze/Defrag

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devonknows
    New Member
    • Nov 2006
    • 137

    Analyze/Defrag

    Good afternoon, if anyone can help me with this i would be most appreciative

    Im looking for a way to invoke the Defrag through visual basic, the defrag part i can do but i want to be able to analyze it first, to see if actually needs defragmentation

    i know you can use Run
    --> CMD --> defrag.exe C: -A
    to analyze it, but the question is does it log it anywere? if it writes to a log file then i can just read the logfile.

    The problem is i have a lot of hard drives contained within my computer, and files are always being moved, deleted, transferred, renamed and general havoc really so i want to write an efficient program in vb that will take control of that side of it so its one less thing to worry about. I noticed a post on defrag vbscript but cant makes heads or tails out of it.

    Any help would be appreciated

    Thank you
    Kind Regards
    Devon.
  • pureenhanoi
    New Member
    • Mar 2007
    • 175

    #2
    Im looking for a way to invoke the Defrag through visual basic, the defrag part i can do but i want to be able to analyze it first, to see if actually needs defragmentation
    This is a big problem. Thats better if you use existing Defragment Tool from Windows

    i know you can use Run
    --> CMD --> defrag.exe C: -A
    to analyze it, but the question is does it log it anywere? if it writes to a log file then i can just read the logfile.
    If you want log to file, so do this command: "DEFRAG C: -A >D:\LogFile.TXT "

    The problem is i have a lot of hard drives contained within my computer, and files are always being moved, deleted, transferred, renamed and general havoc really so i want to write an efficient program in vb that will take control of that side of it so its one less thing to worry about. I noticed a post on defrag vbscript but cant makes heads or tails out of it.
    Defragment Tools can be schedule to run any time, any where (any driver) as you want

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      This link seems as though it may be relevant, though probably not exactly what you're looking for.

      The interesting part starts about half way down, with "Provide Event Logging for Disk Defragmenter Utility with WSH".

      Comment

      • devonknows
        New Member
        • Nov 2006
        • 137

        #4
        Thank you both for the input, very helpful, now im faced with another difficutly, i wish to do the Defrag Analyze silently. but when i try and shell

        %SystemRoot%\Sy stem32\Defrag.e xe C: -a -v >D:\LogFile.t xt

        the window just appears and disapears and does not process the command and when i try and when i shell the command

        %SystemRoot%\Sy stem32\CMD.exe /c defrag.exe c: -a -v >D:\LogFile.t xt
        (/c Switch terminates window after use)

        it shows up the window, now is there anyway to make this window hide, or appear off the screen, i just dont want like 8 different command prompt windows popping up one after the other lol.

        Thanks Again
        Kind Regards
        Devon

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Just from memory, doesn't Shell have one or more parameters that let you specify whether to run maximised/minimised, with/without focus?

          Comment

          • devonknows
            New Member
            • Nov 2006
            • 137

            #6
            Originally posted by Killer42
            Just from memory, doesn't Shell have one or more parameters that let you specify whether to run maximised/minimised, with/without focus?
            Thank you kindly, least someone has got their head screwed on, i remember when exactly what it was as soon as you mentioned Maximised/Minimised... It was the hide one. I will display the basic code for the primary question.

            [CODE=vb]
            'This code will Analyze drive C with the Administrator/Developer defrag Application
            '(C:\Windows\Sy stem32\defrag.e xe)
            'Switches -
            ' CMD: /c (Closes the CMD window after completion
            ' Defrag: -a (Analyze Only) -v (Verbus Output) >d:\lg.log (Outputs Data To File)

            Shell "C:\Windows\Sys tem32\CMD.exe /c defrag.exe C: -a -v >C:lg.log", _
            vbHide
            [/CODE]

            Shell Options:
            vbNormalFocus
            vbNormalNoFocus
            vbMaximizedFocu s
            vbMinimizedFocu s
            vbMinimizedNoFo cus
            vbHide

            As much basic information as i can think of but thanks for your help, Both of you :-)

            Kind Regards
            Devon

            Comment

            Working...