Reset if error found

I have a process that some times it fails and leaves the process un-finished.

I need for the process that if in cases of error to reset and start again. By reset, I mean to close all open applications related to the process and start again.

Therefore, the first question is, how can I prevent for the process to fail. Basically if the process fails then reset and start again.

The second question is, how can I check if an application is open and if it is close it. Is it possible to do it through task manager, vba or command prompt?


you can handle in main Try Catch and Finally, and in the Finally have a Close Application Sequence, you can use CloseApplication Activity ( you can specify ContinueOnError as True ) and TimeOutMs 2000 under Target, ( this would automatically handle if the application is opened it will close , else it will continue in 2 seconds

this Try Catch can be with in a While Loop , till it is successful on the process, you can keep restart the application within the bot

1 Like


Thanks for your message.

I’m not sure if I get all your comments. I’ve added the TryCatch activity, but I’m not sure what is the function of the Finally part. Initially I’ve used it to capture that there was an error (errorFound), but then the processes was not completing. I’ve moved the ErrorFound assignment to the Catches section, but I’m finding the the process ends rather than being permanently on.

I’m not sure I understand what you mention in relation to closing the activity.

I’m starting the robot with the following command (in case it makes any difference):
C:>“C:\Program Files (x86)\UiPath Studio\UiRobot.exe” /file:“C:\Users\FINROB1\Desktop\Share\OnDemand\Main.xaml” /target\finrob1 /monitored

I’m not sure if I have a problem with the catch try or with how I’m initiating the robot.

Any ideas?

Main.xaml (250.0 KB)

Finally will be used to close all the opened files, folders, Application to free all the memory we are using…

Paste all your code in Try Block and in Catch Block maintain a variable to detect that Exception and make a decision to run that try again…

This logic may help you…

Please be revert with response:slight_smile:



I tried your process (attached), but it doesn’t seem to work :disappointed_relieved:. The process stills ends. Do I also need to loop the monitor events > CheckIfNewFile? I would think that this would need to run continuously.

MainCatch.xaml (239.2 KB)

Hi @selrac,

I am also facing same issue after adding try catch in while loop when I am running process through cmd in background. The process ends.

Have you found any solution?

Please help!

Thank You,