cancel
Showing results for 
Search instead for 
Did you mean: 

setforegroundwindow issue on a focus

RobertLatherow
Level 3
I'm testing some code another coworker wrote, and it's bombing out in a very exotic way. Exception during remote setforegroundwindow - System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at BluePrism.ApplicationManager.clsLocalTargetApp.ForceForeground(IntPtr hwnd) I have had this error before on an 'Activate' action, and it was usually because I had only grabbed a portion of the W32 window and not the entire browser. I have no idea what to even look at on a Focus step. The element is a text input on the page, highlights fine, and is using AA attributes. At the point this fails, the action has already focused on 7 or 8 other fields with no issues. Anyone have any thoughts? -rj
7 REPLIES 7

ShreyansNahar
Level 5
Can anyone help on this? We are facing similar exception while trying to run a demo on someone else's system using Lync/Skype.

Denis__Dennehy
Level 15
Setforeground window errors usually occur where the desktop does not exist - so the screen is locked or you are connecting to the resourcepc via RDP and disconnect. For global interactions (Activates, Global Clicks, Global sendkeys) to work the desktop needs to exist and not be locked. The VM technology that is used needs to provide persistance and consistancy (unlike RDP connections) - Please refer to the product documentation and reference guides.

JayaPrakash
Level 3
Try recovering the exception on the business object page, wait 10 second, and then try once more. I've had previous experience where Activate would throw an exception for no obvious reason, and simply retrying would usually work. It's more of a workaround than a cure, but it might allow you to progress.

Anonymous
Not applicable
Apologies for dragging up a 2-month old thread but thanks to Jaya for that tip. I had exactly the same problem where BP was throwing up this exact error when it tried to close the save banner in Internet Explorer. Remarkably, just trying again nearly always fixed it.

lakshminarayan1
Level 2
Hi latherow, I am facing the same error shown below, ERROR: Internal : Failed to perform step 1 in Navigate Stage 'Activate the Main Application' on page 'Authentication' - Exception during remote setforegroundwindow - System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at BluePrism.ApplicationManager.clsLocalTargetApp.ForceForeground(IntPtr hwnd)   Could you please help me with the solution if you got any.  

Denis__Dennehy
Level 15
Lakshmi - the answers are already above in this thread.  Either your virtual desktop does not have a persistent visual screen, or you are using an application such as RDP to connect/disconnect (which our guides say not to use), or your virutalized environment has some kind of issue that might be fixed by having a retry loop that tries again after a few seconds.

Ernest1
Level 5

Sorry for the late message, but maybe it will be helpful.

In my case, this problem occurred when the browser screen was long and the robot tried to click a button that was located at the very bottom and was invisible on the window.

I solved it in three steps:
1. focus on button (scrolls the window to the bottom/or top for a specific button)
2. click the button
Additionally, I added a 0.5 sec pause each steps