Sign in to follow this  
Followers 0
Scottswan

WinWait ignoring command windows

6 posts in this topic

I can't seem to find a way to get this script to wait for an active command prompt window to close. It keeps ignoring me and jumping on to the next step.

;Say Hi!
MsgBox(4096, "Server Backup", "The Metadot server will unload and perform a full HD backup in 10 seconds", 10)

;Kill Metadot
Run("C:\data\service_stop.bat")
Sleep(250)
$shutdown = WinWaitClose("C:\WINNT\System32\net.exe")
If $shutdown < 1 Then
ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
EndIf

Sleep(1000)
$step1 = MsgBox(4, "Step 1", "Do you want to run xxclone?")
If $step1 = 7 Then 
Exit
EndIf

Run("C:\WINNT\system32\xxclone.exe")
Sleep(2000)
MouseMove(600, 440)
MouseClick("left")

The "Kill Metadot" is where I'm stuck. That shutdown can take anywhere from 2 seconds to a minute to finish.

I last added a If Then loop and a process indicator but even that was ignored.

I checked the window title using AU3info even!

Is there something unique about command prompts I should know about?

-Scott

Share this post


Link to post
Share on other sites



I am not sure what the answer is but I think you are on the right track thinking it is something to do with the command prompt.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I am not sure what the answer is but I think you are on the right track thinking it is something to do with the command prompt.

This works...

WinWaitClose("C:\WINNT\System32\cmd.exe")

MsgBox(4096, "Hey Hey", "It waited....or not.", 10)

Go to Start - Run and type "cmd", then run this script and it sits there quietly until I x out the cmd box.... just like it's supposed to do!

Hmm, maybe I'm running into a CPU cycle bug with the other one, that net.exe is actually launched from a batch file which does a bunch of different stuff to shut down Metadot.

Maybe I'll just have to put in a long delay before running the backup, it's eventually going to be running at O'dark thirty in the AM anyways... nobody will be around to see it.

Share this post


Link to post
Share on other sites

My homemade, free RAID backup...

;Say Hi!
MsgBox(4096, "Server Backup", "The Metadot server will unload and we will perform a full HD backup in 10 seconds", 10)

;Kill Metadot
Run("C:\data\service_stop.bat")
Sleep(500)
WinWaitClose("C:\WINNT\System32\net.exe")
Sleep(8000)

;Run the backup utility
Run("C:\WINNT\system32\xxclone.exe")
Sleep(3000)
MouseMove(600, 440)
MouseClick("left")
Sleep(1000)
Send("{Enter}")
WinWaitActive("XXCLONE Done!")
Sleep(1000)
Send("{Enter}")
Sleep(1000)
MsgBox(4096, "Server Backup", "All done! The Metadot server will restart in 5 seconds", 5)

;Run Metadot
Run("C:\data\service_start.bat")

Run with Scheduler nightly and it makes a bootable clone of an entire HD. :P

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Did you try RunWait?

Runs an external program and pauses script execution until the program finishes.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Did you try RunWait?

Just tried that, no dice. I think the CPU is too busy for Autoit to monitor the status of that window.

-Scott

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0