How to pause a bot

Hello folks,

I have a bot that runs and does a few tasks. It recently came up where there was a situation in which the ability to pause the bot at my discretion would have been useful. Does such a functionality exist?

Ideally I could just hit a button or run a command of some kind that pauses the bot where it is and then have it resume from that point at a later time.

The good old MsgBox(“stop”) (You have an activity for Message box,) will do the trick if you run the bot in an attended way.

Cheers

2 Likes

So just to make sure I am understanding you…

Are you suggesting that I have my bought throw up a message box which at such time stops the bot from doing anything else and then I can just click “Okay” on the box to have it start again?

Exactly.

1 Like

Gotcha.

Unfortunately that won’t quite suite my needs.

I have a process that it takes a Robot anywhere between 60 and 70 minutes to complete. What I am trying to implement is the ability to pause that bot at any arbitrary point in the process (similar to how one might suspend a windows process) and then lets me resume it later.

If I were to put a message box in the process that would effectively pause the bot, but unless I am misunderstanding it would only be able to pause it once the workflow reaches that point with the message box. Anything prior to or after that point would be “unpauseable” without implementing another Message Box activity.

Now you have given me an idea. Since the bots themselves run on WWF then perhaps I could run a task parallel to the process doing the work and set that task up such that when a button is clicked it executes a script and that script suspends the windows process running the thread the bot works in.

2 Likes

I see, yes this is not on demand definitely.
Yeah your idea is interesting.

Something I wanted to try some time ago (but I didnt) is to pause the UiRobot service, I actually have no clue if it would work out.

Possibly UiRobot does not inplement the pause method.

You should be able to do it from services.msc.
I cannot try right now, Im from my phone.

Cheers

1 Like

Thanks for the help man.

I’ll give my idea a try tomorrow and see how it goes.

Hey.

Here is an idea I built quickly to demo a potential pause mechanism. But the thing is that you would need to place a Loop or Trigger of some kind between each important task so it can Pause and Continue. This mechanism uses a Parallel with a Monitor Event and a boolean variable that toggles so the main sequence can pause.

This demo uses an Enter key to pause and outputs to the Write Line to display that it is pausing for you.
PauseDemo.xaml (12.1 KB)

It’s probably not the best solution out there, but thought it might strike some other ideas too with your other one.

Good Luck.

4 Likes

Hi, I’m new to RPA but was also looking for this type of functionality. Your PauseDemo is a nice addition and I have not found a better solution yet, but wanted to add some thoughts for clarity. The Do loops of the left side process, ie the main process, only sees the pause event (triggered by the Monitor Activity) when the boolPause Do loop is placed at various locations within the main process. It is effective to break up the main process and pause it a these placed locations, but it doesn’t ‘monitor’ the main process for a Pause event per sa. But, again, nice addition until a better mechanism is found. Thanks for sharing.

You maybe set some stage at that process…
Example… set a temp folder Data\temp
filename 1 to stage 1 and so on…
At start you can read that folder and depend of what file it contains the process jump to respective stage… but remember to clean in the end of the last stage.
So you can stop it at that certain stage… is not perfect, but its somenthing.

Understand?? English is not my native language so sometimes is difficult to express myself.

image

Alright folks here is what I turned up this morning.

The highlighted process seems to be the process that the bot runs under and I found that if you suspend that process (right click it and hit suspend) and stops the process from using anymore cpu cycles but it does not dump the memory which means that the bot can resume from where it left of.

I tested this by making a bot that just counts and I suspended that process when the bot got to 67 and when I resumed it the bot picked back up at 68.

So it looks like that you can in fact pause a bot on demand at any arbitrary point and have it resume at that point by just running a 2 line power shell script.

4 Likes

Hi, two points.

  1. @ClaytonM, your PauseDemo needs a minor change on the left parallel. You have a Do-while to test if the boolPause parameter is triggered, but this needs to be a While statement. This is important if you place code before and after the trigger test such as placing in a main sequence at various locations. The While statement only pauses if boolPause is True, but a Do-While will enter this loop at least once. Perhaps that is ok, since it will just pass through a timer, but maybe you want to do something during the pause…
  2. @FireflySeason2, this is interesting. Are you suggesting to use InvokePowerShell ? It seems this is the same problem as with the PauseDemo, you need to place a test for the pause trigger at various locations within the main sequence. I have not used PowerShell, so I am not sure about this point. Could you please elaborate on the two-line code and how you implement that code within UiPath? How could you make this trigger at an arbitrary point in a main sequence.

Thanks.

@DPF16
Excellent point about using a While instead so you can perform other actions if needed.

I think @FireflySeason2’s idea was suggesting to place the InvokePowershell in a Parrallel with Monitor Events similar to PauseDemo. In theory, it would execute anytime you press a key and suspend the executor until you press a key again, or something like that.

Hi,

I am suggesting that for this particular business need I have (the need of being able to pause a bots execution at will and have it resume from the pause point when I say so) that I intend to bypass UIPath its and just directly run a powershell that suspends that UiPath.Executor process.

I am going to test this out more latter this week but this morning’s work was promising.

And ClaytonM’s idea of just having this as a parallel task with a button InvokingPowershell would probably work too but that would have the caveat that because the product itself is leveraging WWF that that bot is single threaded so before your button mounted pause command goes through there would have to be a break in that thread’s usage. It would also have to be considered how you might actually click that button if the bot is actively using screen.

Well done!
I will definitely reuse the approach a future for some of the stuff I’m working on!

Cheers

You can use User Preference option from UI Path Robot:
2019-07-19%2017_59_39-How%20to%20pause%20a%20bot%20-%20RPA%20Dev%20Rookies%20-%20UiPath%20Community%20Forum
image

3 Likes

aha,that official way should be based on the process,usefull

Hi, May I know on what version of robot this user preferences exists? this option is not available to me.
Thanks,
Kenneth

Hi Kenneth,
In current version of uipath(19.8.0), you can find User Preference related activity in Robot setting Option → Keyboard Shortcuts:
image

Thanks,
Praloy

Hi,

thank you.