Imacros scripting interface - how to recreate in UIV?

The iMacros Enterprise Edition automatically installs theScripting Interface. You can control iMacros with any Windows programming language that supports the use of COM objects.

Almost all Windows programming languages support this technology, including the free Windows Scripting Host, Visual Basic 6, Visual Basic .NET, C#, Java, Perl, Python, C++, ASP, PHP, ASP .NET. On the iMacros homepage many examples for different programming languages can be found.

=> I know there is a command line API in UIV, but I am a bit lost on how to get started.

For example, how to convert the VBS script shown here:

'initialize Scripting Interface
Set iim1 = CreateObject ("IMacros")
i = iim1.iimOpen() 

' setting variables
i = iim1.iimSet("name", "Tom Tester")
i = iim1.iimSet("age", "34")

' displaying message
i = iim1.iimDisplay("This is a test")

' play macro
i = iim1.iimPlay("myfirstmacro")

' check success
If i > 0 Then
  s = "Everything OK"
  s = iim1.iimGetErrorText()
End If
MsgBox s

' exit iMacros
i = iim1.iimClose()

Nice question. You can achieve exactly the same what the iMacros Scripting interface does with the UIV RPA command line.

Sample code for VBS, Powershell, Python,… etc can be found here:

In the following I explain how to replace each imacros scripting interface command by the corresponding UIV code. (VBS example code, same works also in Python etc).


This is done by starting the browser (Chrome, Edge, Firefox) directly using a special URL:


In UIV RPA you can use the special command line parameters &cmd_var1, &cmd_var2,… to send values from the script to the macro/browser extension:

In the macro you can retrieve these values in the ${!cmd_var1}, ${!cmd_var2},… variables.


You can instruct the UIV extension itself to display a popup with the ECHO command:

iMacros Alternative: iimDisplay


We provide sample code for a β€œPlayAndWait” function in many programming languages. This can be used whereever you use(d) iimPlay in your script.

You can start many macros directly after another by calling β€œPlayAndWait” and then again β€œPlayAndWait”.


The β€œPlayAndWait” function also retrieves the error message/success message from UIV. See the image above (code marked in blue).


With UI Vision (UIV) you close the app by telling it via command to close after the macro is done. If you add &closeRPA=1 the UIV user interface is closed, and if you add &closeBrowser=1 then the browser is closed, too.

Note that all of this works on Windows, Mac and Linux. UIV is a cross-platform automation solution.

Here the the VBS script in action:

PS: For more information see our iMacros alternatives help page

1 Like

That’s great to know, but where to put them in the .vbs?
I’ve added the PlayandWait function and tried numerous configurations to get the .json script to run, but nothing doing. It will not play, remotely I should add. I can get the vbs to run by double clicking it and it runs the json, without reading the varDictionary parameters. But we need it to be run remotely by our Password Management software that runs iMacros currently.
Here is the current vbs script we use for iMacros:
β€˜β€™β€˜β€™β€˜β€™ MAIN β€˜β€™β€˜β€™β€˜β€™
On error resume next

’ Actions
Const ACTION_TYPE_VERIFY = β€œverifypass”
Const ACTION_TYPE_CHANGE = β€œchangepass”
Const ACTION_TYPE_RECONCILE = β€œreconcilepass”
Const ACTION_TYPE_PRE_RECONCILE = β€œprereconcilepass”
Const ACTION_TYPE_LOGON = β€œlogon”

Dim Rc
Dim LogonPassword
Dim CurrentPassword
Dim NewPassword
Dim ReconcilePassword
Dim ExtractedData
Dim timeout

if WScript.Arguments.Count < 8 Then
RaiseException -1, β€œMissing arguments. Usage " & wscript.ScriptName & " /action: /macro: /logonuser: /logonaddress: /username: /reconcileuser: /timeout: /debug: [additional args]”
End If

’ Get the logon password
Wscript.StdOut.Write wscript.ScriptName & " Enter the password used for logon: "
LogonPassword = Wscript.StdIn.ReadLine

’ Get the current password
Wscript.StdOut.Write wscript.ScriptName & " Enter the current password: "
CurrentPassword = Wscript.StdIn.ReadLine

’ Get the new password
Wscript.StdOut.Write wscript.ScriptName & " Enter the new password: "
NewPassword = Wscript.StdIn.ReadLine

’ Get the reconcile password
Wscript.StdOut.Write wscript.ScriptName & " Enter the reconcile user password: "
ReconcilePassword = Wscript.StdIn.ReadLine

’ Initialize the iMacros browser (Chrome=cr, IE=ie, iMacros=ng)
set ObjiMacros = CreateObject(β€œimacros”)
Rc = ObjiMacros.iimOpen(β€œ-cr”, True)

ErrorHandler Rc, β€œFailed to initialize iMacros Browser”, ObjiMacros

'replace all args based on command-line names
Set objArgs = Wscript.Arguments
For i = 4 to objArgs.Count-1
ArgName = GetArgName(objArgs(i))
Arg = GetArg(objArgs(i))
Rc = ObjiMacros.iimSet(ArgName, Arg)
ErrorHandler Rc, "Failed to initialize variable " & ArgName, ObjiMacros

'key-value pairs for hard-coded arguments
Dim varDictionary
Set varDictionary = CreateObject(β€œScripting.Dictionary”)
'usernames and address
varDictionary.Add β€œusername”, WScript.Arguments.Named(β€œusername”)
varDictionary.Add β€œextrapass1username”, WScript.Arguments.Named(β€œlogonuser”)
varDictionary.Add β€œextrapass3username”, WScript.Arguments.Named(β€œreconcileuser”)
varDictionary.Add β€œaddress”, WScript.Arguments.Named(β€œlogonaddress”)
varDictionary.Add β€œextrapass1”, LogonPassword
varDictionary.Add β€œpmextrapass1”, LogonPassword
varDictionary.Add β€œpmpass”, CurrentPassword
varDictionary.Add β€œpmnewpass”, NewPassword
varDictionary.Add β€œextrapass3”, ReconcilePassword
varDictionary.Add β€œpmextrapass3”, ReconcilePassword

'iterate through dictionary, set values
keys = varDictionary.Keys
For i=0 To varDictionary.Count - 1
key = keys(i)
value = varDictionary(key)
Rc = ObjiMacros.iimSet(key, value)
ErrorHandler Rc, String.Format(β€œFailed to initialize variable [{0}]”, key), ObjiMacros

'Setting time default 90 seconds as timeout not recieved
timeout = WScript.Arguments.Named(β€œtimeout”)
If (IsNull(timeout) Or (strComp(timeout,β€œβ€) = 0)) Then
timeout = 90
End If

’ Execute the task by playing the macro
macroPath = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, ""))

Rc = ObjiMacros.iimPlay(macroPath & WScript.Arguments.Named(β€œmacro”) & β€œ.iim”, timeout)

ExtractedData = ObjiMacros.iimGetLastExtract()
Wscript.StdOut.Write ExtractedData

ErrorHandler Rc, "Failed to play the macro: " & WScript.Arguments.Named(β€œmacro”), ObjiMacros

’ Check if we need to take screeshot, only in case debug is enabled
If (StrComp(WScript.Arguments.Named(β€œdebug”), β€œYes”, 1) = 0) Then

logPath = Left(macroPath, InstrRev(macroPath, "", Len(macroPath) - 1))
Rc = ObjiMacros.iimTakeBrowserScreenshot(logPath & β€œ\Logs\ThirdParty\WebApp-” & WScript.Arguments.Named(β€œlogonaddress”) & β€œ-” & WScript.Arguments.Named(β€œusername”) & β€œ-” & Hour(Now) & β€œ-” & Minute(Now) & β€œ-” & Second(Now) & β€œ.png”, 1)
ErrorHandler Rc, "Failed to take screen shot: ", ObjiMacros

End if

Wscript.StdOut.Write β€œDONE”
WScript.Quit 0

β€˜β€™β€˜β€™β€˜β€™ HELPER FUNCTIONS β€˜β€™β€˜β€™β€˜β€™
sub RaiseException(errCode, errDesc)
err.Number = errCode
err.Description = errDesc
ErrorHandler β€œAn error has occured”
End sub

sub ErrorHandler(Rc, PrefixMsg, ObjiMacros)
If Rc < 0 Then
Wscript.Echo PrefixMsg & " (" & Rc & ", " & wscript.ScriptName & "): " & ObjiMacros.iimGetLastError()
Wscript.Quit Rc
End if
End sub

function GetArg(argument)
Dim a
a=Split(argument, β€œ:”, 2)
End function

function GetArgName(argument)
Dim a
a=Split(argument, β€œ:”)
End function

What do you mean by remotely? Where is iMacros installed?

Rc = ObjiMacros.iimPlay(macroPath & WScript.Arguments.Named(β€œmacro”) & β€œ.iim”, timeout)

What is the path to the iMacros macro? Is it a local path or a network path? In any case, the same kind of path would work for macros as well.

Remotely is probably the wrong term to use, more like unattended.
The password management software will log into the server and run the vbs script which in turns runs the iMacros script.
If you are familiar with iMacros and CyberArk you’ll understand what I need this to do.
All of the scripts are local to one server, and will run with no β€œHuman” intervention

Basically what I need to figure out is how to get the correct username from:
varDictionary.Add β€œusername”, WScript.Arguments.Named(β€œusername”)
To be entered into the username field of the webpage using &cmd_var1
arg = Chr(34) & path_autorun_html & β€œ?storage=xfile&macro=” & macro &β€œ&direct=1&savelog=β€β€œ&cmd_var1=” & username & β€œ&cmd_var2=” & password & Chr(34)
Works fine, however the &cmd_var1 variable remains empty.
If I assign something to username, username = (β€œusername”), that’s what get entered.
Need something similar to
username = WScript.Arguments.Named(β€œusername”)
The username will change for every script and writing a .vbs for each one really isn’t feasible.