Start Trial

20 December 2019

RPA Tutorial: Close Window vs. Close Application vs. Kill Process Activities

20 December 2019

RPA Tutorial: Close Window vs. Close Application vs. Kill Process Activities

⬅  SEE ALL THE ARTICLES

 

Many UiPath developers use the Robotic Enterprise Framework (REFramework) for their automations. Regardless of their choice for standard or customized processes, this framework is reliable because it already includes many of the best practices for successful automation.

 

Yet, when it comes to the part where applications, browsers, etc. need to be closed, developers have three activity options:

 

1. Close window
2. Close application
3. Kill process

 

These options often lead to questions about the best approach and the most appropriate activity to use.

 

To start, we need to clarify that each of the options has unique behavior and their own set of pros and cons. To help clarify this, the below table provides two examples for each activity. To make it really easy, the examples cover an app and a web browser scenario.

 

Activity

Windows app scenario

Microsoft Excel Workbook with some unsaved changes

Web browser scenario

Internet Explorer browser window with multiple opened tabs

Close Window

 

Input a Selector or Window type variable

The Close Window command is sent to the application.

 

The Microsoft Excel app displays a prompt asking for the changes to be saved.

 

The workflow proceeds to the next activity without affecting the Application Window status.

 

The Microsoft Excel app and the prompt are left open. If the changes are saved, though, this behavior does not happen.

 

The activity will not display any kind of error.

The Close Window command is sent to the browser.

 

If multiple tabs are open, the browser tab displays a prompt asking for a confirmation to “Close all tabs.”

 

The workflow will proceed to the next activity without affecting the browser window status.

 

The browser and the prompt are left open.

 

The activity will not display any kind of error.

Close Application

 

Input a Selector or UIElement type variable

The Close Window command is sent to the application window.

 

The Microsoft Excel application will display a prompt asking for the unsaved changes to be saved.

 

The activity will pause for 30 seconds (default timeout) before the application process closes gracefully.

 

As soon as the timeout window is closed, the application process is killed (similar to the Kill Process activity).

 

The Excel application is closed and the unsaved changes are lost.

 

The next time the document is opened, the Document Recovery options will be displayed on the left pane.

The Close Window command is sent to the browser.

 

In case multiple tabs are opened, the browser app will display a prompt asking for a confirmation to “Close all tabs”.

 

The activity will pause for 30 seconds (default timeout) before the Browser Application Process closes gracefully.

 

As soon as the Timeout window is closed, the Browser Application Process is killed (similar to the Kill Process activity).

Kill Process

 

Input – Process Executable Name (e.g. excel, iexplore”) or Process Type Variable

The Application Process is killed (similar to the End Task from Task Manager).

 

The Excel application is closed and unsaved changes from the Workbook will be lost.

 

The next time when the document is opened, the Document Recovery option will be displayed on the left pane.

The Browser Application Process is instantly killed (similar to the End Task from Task Manager) without any attempts to soft close it.

 

Follow the below steps to close any application or browser which displays a Prompt/Dialog interrupting closure.

 

Note: this is an example inspired by the Windows application scenario discussed in the table above.

 

pic

 

You can use the CloseAllApplications.xaml of REFramework or other suitable workflows from your project. The main principle is to use the Close Window activity in combination with the Element Exists activity.

 

Approach:

 

  • • The Element Exists activity has a default timeout set to 3000 milliseconds (three seconds). This is the standard value for UiPath Studio version 2019.4.2 but it can be changed based on your knowledge of the application’s behavior. It is going to wait up to three seconds for the Prompt/Dialog window to be displayed. If it shows up, the Output for Element Exists activity will be set as True, otherwise, it will be marked as False. 

 

• The Output is received in a variable, e.g. promptExists, which is then checked using the Flow Decision activity.

 

• If the value of the promptExists variable is True a Click activity is used. This will click the Save button on the Prompt/Dialog window and complete the application closure process.

 

If the above flow cannot be used, the Close Application activity is the next best option. It has a default timeout of 30 seconds that can be adjusted as needed.

 

Knowing exactly how to use activities that seem similar is an important step in mastering your UiPath Studio automations.

 

My advise is to immerse yourself in all the available activities packs and keep in mind that only the sky is the limit.

 

 

Sagar Agrawal is an RPA technical architect at UiPath.


by Sagar Agrawal

TOPICS: Learning RPA, RPA, RPA Tutorial

Show sidebar