Jump to content

WinWaitClose doesn't work for second instance of a window


Go to solution Solved by mikell,

Recommended Posts

Hi folks,
I have the below script which is really testing my patience :P
It opens a cmd console (Raven.Smuggler.exe), exports a database, connects to VPN, imports the database (again Raven.Smuggler.exe), disconnects from VPN - and the idea is that the WinWaitClose waits for the cmd windows to be closed.
This works fine the first time (when exporting DB) and it doesn't continue the script till the window closes, but when the second cmd window opens (to import DB), it continues right away and disconnects from VPN.
There is no window title on the command window other than "c:RavenDBSmugglerRaven.Smuggler.exe" , but i don't know if it counts as a title or just the path.
I have tried using window title, class, instances etc, but nothing seems to work on the second window. I think it might have something to do with that the windows are alike?
Hope you can help me :)
Opt("WinTitleMatchMode", 2)

; Exports DB
Run("c:\RavenDB\Smuggler\Raven.Smuggler.exe out http://server01:8080/databases/test-develop e:\testdir\")

; Run VPN Client
Run("C:\Program Files (x86)\Cisco Systems\VPN Client\vpngui.exe")
WinWaitActive("status: Disconnected | VPN Client")

; Connects to VPN Server
WinWaitActive("status: Connected | VPN Client")

; Imports DB
Run("c:\RavenDB\Smuggler\Raven.Smuggler.exe in http://server01:8080/databases/test-develop e:\testdir\")

; Closes VPN Client
WinActivate("status: Connected | VPN Client")


Link to comment
Share on other sites

Have you tried getting a handle for the first cmd window?

And then tried the instance with that?

Usually when I use cmd windows (DOS console) I use RunWait or perhaps ProcessWait etc.

You can also try utilizing the pid.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.


What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)


Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...