BoardBabe Posted December 15, 2005 Posted December 15, 2005 I'm calling a defrag of my systemdrive at the very end of my WPI list as follows:call %SystemRoot%\system32\defrag.exe %SystemDrive% -fIs there a way to get a progress bar on this, by launching from AutoIt or something? Would be nice, cause this process takes a while...
MHz Posted December 15, 2005 Posted December 15, 2005 Defrag.exe is not too verbal for even the AutoIt Beta stdio to get information from.You could try to automate the Defrag Gui.Here is some code to get you started.Run(@SystemDir & '\mmc.exe dfrg.msc', @SystemDir)If WinWait('Disk Defragmenter', '', 10) Then ControlFocus('Disk Defragmenter', '', 'SysListView321'); Focus drive selection. ControlSend('Disk Defragmenter', '', 'SysListView321', '{DOWN}'); Next Drive. ControlClick('Disk Defragmenter', '', 'Button1'); Analyze.;~ ControlClick('Disk Defragmenter', '', 'Button2'); Defrag.EndIfThe above will analyze D: drive.
BoardBabe Posted December 15, 2005 Author Posted December 15, 2005 (edited) Oh never mind. Hmm yeh that will bring up the GUI. What would be neat though is JUST a progress bar from autoit, nothing else. But maybe its impossible Edited December 15, 2005 by BoardBabe
blinkdt Posted January 6, 2006 Posted January 6, 2006 Yeah, this one is tough. Tying an action to a process is one thing, but when the process will not reveal itself then you're stuck guessing. I have "settled" on a splash text that hides the command window for the duration of the defrag process:SplashTextOn("", "" & @CRLF & "Defragmenting the C: partition..." & @CRLF & "", 275, 58, -1, -1, 1, "Arial", 12, 12)RunWait ( @ComSpec & " /c defrag c: -f", "", @SW_HIDE )SplashOff()Pretty boring to be sure, but I know it is working and I'm not trying to entertain an audience. I just want it to look clean.Here are some script ideas with promise found at MHz's other hangout: HERE. This adaptation seems to work pretty well, and the $TimeLimit variable can be adjusted with quite a bit of accuracy depending upon the fragmentation level at any given point during the install:Func renew() $TimeLimit = 10000 $start = TimerInit() $pid = Run(@ComSpec & " /c defrag c: -f", "", @SW_HIDE ) ProgressOn( "Progress", "Defragmenting the C: partition") While ProcessExists( $pid ) $current = TimerDiff($start) ProgressSet( $current * 100 / $TimeLimit) Sleep(20) WEnd ProgressOff()EndFunc;==>renewrenew()The required tweaking is well-suited for the perfectionist. If anyone can devise a way to tie a progress bar to the actual length of the defrag process, I will lobby to add another star to their profile.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now