Ways to run Robin in Live environment

How can we schedule or run the robin application in live environment. For example how we have an option to trigger and schedule in WinAutomation, do we have anything like such in Robin or a workaround to do this.

1 Like

(This post was transferred at the “Language” section)

Hi sushanthraikar!

Robin is a programming language for RPA and not an RPA platform.
As such, it doesn’t have trigger/schedule capabilities, at least for the time being.

As a workaround, you could use Windows Task Scheduler in order to run Robin scripts at requisite intervals.


James Papadimitriou
Robin Technical Evangelist

1 Like

@sushanthraikar please have a look at my latest guide here:

Best regards,
J.


James Papadimitriou
Technical Evangelist

1 Like

Here is a way to run Robin.exe with AutoHotkey, which is very useful for RPA tasks.

AutoHotkey can provide ad hoc methods for automation scenarios that are difficult or impossible to address using only the standard language of a platform. Powershell, python, AutoIT, VBScript, REXX and the various C# scripting languages, among others, are extremely helpful for RPA as well. They all have their strengths and weaknesses.

Problem: How can I create an executable (.exe, that is) that will run a Robin script without calling Robin.Editor? (@jpap has provided one way, and I’m looking forward to the Powershell version too :slight_smile: ) .

Sub-problem: At least on my system, running a desktop automation script via Robin.exe from the command line leaves two (2) instances of conhost.exe running, and two (2) instances of Robin.BridgeToUiAutomation.exe running. This might create issues if many scripts are run without garbage collection.

Here are shots from Win7 Task Manager showing where “conhost.exe” and “Robin.BridgeToUiAutomation.exe” would show up on my system if they were running:

conhost%20before

and

uibridge%20before

Now I’ll run a script from the command line, like so:

C:>robin run C:\Users\burque505\Documents\Robin\notepad4.exe

The script executes without a problem.

Here are some screenshots of what’s left running afterwards:

conhost%20after

and

uibridge%20after

What to do?

Partial solution: Autohotkey script (uncompiled):

; +-----------------------------------+
; ¦  run as admin                     ¦
; +-----------------------------------+

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

; +------------------------+
; ¦  Run the Robin script  ¦
; +------------------------+
RunWait, cmd.exe /c robin.exe run %A_MyDocuments%\Robin\notepadex4.robin

; +-----------------------------------------------------------+
; ¦  Clean up conhost.exe and Robin.BridgeToUIAutomation.exe  ¦
; ¦  created by above process.                                ¦
; ¦                                                           ¦
; +-----------------------------------------------------------+

Process, Exist, conhost.exe
Process, Close, %ErrorLevel%
; ErrorLevel contains the process ID. I won't go into AutoHotkey syntax,
; which some have described in unkind terms :). You get used to it.

Process, Exist, conhost.exe
Process, Close, %ErrorLevel%

Process, Exist, Robin.BridgeToUIAutomation2.exe
Process, Close, %ErrorLevel%

Process, Exist, Robin.BridgeToUIAutomation2.exe
Process, Close, %ErrorLevel%

Process, Exist, Robin.BridgeToUIAutomation2.exe
Process, Close, %ErrorLevel%

The instances of conhost.exe and Robin.BridgeToUiAutomation are gone. In the process above, as briefly referred to in comments in the code, calling

Process, Exist, conhost.exe

causes the process ID to be stored in the built-in Autohotkey variable “ErrorLevel”. Due to the syntax requirements of Autohotkey, this variable needs to be enclosed in “%” symbols to get the value, as in

Process, Close, %ErrorLevel%

right below it. So far so good.

Further steps: You probably want an executable, not another script to run, which to some extent defeats your purpose. AutoHotkey provides a couple of ways to compile scripts such as the one above (visit the AutoHotkey site for lots more info).

The “compiled” script actually contains an instance of the AutoHotkey executable which runs the script. Compiling in optional resources can be done, but isn’t trivial. Perhaps the easiest thing to do, which has the advantage of easier script maintenance, is to include the *.appmask and *.robin scripts in the same folder as the executable. On my machine, the files in the folder look like this:

(For my script above, I had to add an extra

Process, Exist, Robin.BridgeToUIAutomation2.exe
Process, Close, %ErrorLevel%

at the end of script, as it was leaving either leaving an instance of Robin.BridgeToUiAutomation.exe or creating an extra one, not sure which. :grinning:)

I replaced the executable’s icon to the Robin icon with Resource Hacker because it’s really easy to do. but there are other ways.

It doesn’t solve potential issues with UAC you might have. See one of the better guides on using Task Scheduler to do this.

I look forward to your experiences with this and comments.

Regards,
burque505

2 Likes

Nice guide @burque505!
It would be great if you could turn it into a separate post!
I will try replicating it and check the aforementioned issues.

Best regards,
J.

Technical Evangelist