Get-UiaWindow fails if waiting too long

Mar 8, 2016 at 4:04 PM
I am automating a setup wizard. The process is basically

1 - Launch the setup
2 - Search for the window using
Get-UiaWindow -Name "Setup Wizard" -WithControl @{controltype="text";name="Some text on the window"} -Seconds 900
The reason we search for a control on the window is that the name of the window and most of it's properties don't change, only the content.

3 - Click on the Next button
4 - Repeat number 2 and 3 for all steps in the setup

This goes well until we get to the "Setup completed" screen. On this screen, Get-UiaWindow doesn't work anymore. The command doesn't succeed, but it doesn't fail either, even if I wait for the timeout to finish!

The strange part is that if I retry the Get-UiaWindow command with the "Setup completed" screen already present, it does work.

So it looks like the long wait until the "Setup completed" screen (about 8 minutes) causes the Get-UiaWindow command to fail, while a small wait (in previous steps) or no wait (when launching the command with the screen already present) works.

Any ideas on what could be going on, or how to debug this further?

Thanks a lot in advance!
Apr 23, 2016 at 6:40 PM
Edited Apr 25, 2016 at 10:08 PM
Hi cristiannice,
I'm sorry I missed your request.
I think this is because the last step's window belongs to another process. Check its process id (PID) in Task Manager. Setup frameworks sometimes do such a trick, probably with the last screen or with a screen that is seen only sometimes (only in the back direction6 for example, or an automatic screen with names of files and without the Next button).

Alternatively, your last screen may have a new handle.