473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Analyze/Defrag

devonknows
137 100+
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.
Aug 15 '07 #1
5 4344
pureenhanoi
175 100+
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
Aug 15 '07 #2
Killer42
8,435 Expert 8TB
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".
Aug 15 '07 #3
devonknows
137 100+
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%\System32\Defrag.exe C: -a -v >D:\LogFile.txt

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

%SystemRoot%\System32\CMD.exe /c defrag.exe c: -a -v >D:\LogFile.txt
(/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
Aug 15 '07 #4
Killer42
8,435 Expert 8TB
Just from memory, doesn't Shell have one or more parameters that let you specify whether to run maximised/minimised, with/without focus?
Aug 16 '07 #5
devonknows
137 100+
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.

Expand|Select|Wrap|Line Numbers
  1.     'This code will Analyze drive C with the Administrator/Developer defrag Application
  2.     '(C:\Windows\System32\defrag.exe)
  3.     'Switches -
  4.     '     CMD: /c (Closes the CMD window after completion
  5.     '  Defrag: -a (Analyze Only) -v (Verbus Output) >d:\lg.log (Outputs Data To File)
  6.  
  7.     Shell "C:\Windows\System32\CMD.exe /c defrag.exe C: -a -v >C:lg.log", _
  8.                                        vbHide
  9.  
Shell Options:
vbNormalFocus
vbNormalNoFocus
vbMaximizedFocus
vbMinimizedFocus
vbMinimizedNoFocus
vbHide

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

Kind Regards
Devon
Aug 18 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Jim Hubbard | last post by:
Anyone got any info or code examples on defragging your hard drives?
2
by: csomberg | last post by:
SQL 2000 We took SQL Server offline last night and defragged the SAN. Should we reindex or will be be okay ? Thanks, Craig
0
by: Isaac | last post by:
You can perform a defrag by moving tablespaces. Is there a generic script that I can use to run after hours?
1
by: Mohammad-Reza | last post by:
Hi Please tell me how I can defrag my memory. Is there any component that can do this? Is it possible in .NET to do this? How can I do this? Thanks in advance
2
by: Jim Hubbard | last post by:
Anyone got any info or code examples on defragging your hard drives?
1
by: iwdu15 | last post by:
hi, i was wondering if anyone could help me or show some sample code to run disk defrag and handle the error if theres less than 15% free space...ive tried but i cant seem to get it to start to...
2
by: jaeden99 | last post by:
I have found a vbscript on the internet that I would like to add some additional info to: See below. I want to be able to get and save the computer name to each defrag log on a specified server...
4
by: =?Utf-8?B?TG95ZCBDb3VudHM=?= | last post by:
My defrag stoped on windaws Visea Home. I have tried everything I know and it just wont work. I tried it in TOOLS and in MY COMPUTER opening C: and hit properties and pull tools and hit...
2
by: =?Utf-8?B?RHVhbmU=?= | last post by:
I unistalled Norton Ghost 14.0 and when I went to defrag my HD, I got this error -- basically saying it could not defrag the HD. Here are the specifics of my results. Any help is appreciated!...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.