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β
βDeclarations
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
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
Next
'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β)
'passwords
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
Next
'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
ObjiMacros.iimClose()
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()
ObjiMacros.iimExit()
Wscript.Quit Rc
End if
End sub
function GetArg(argument)
Dim a
a=Split(argument, β:β, 2)
GetArg=a(1)
End function
function GetArgName(argument)
Dim a
a=Split(argument, β:β)
GetArgName=Mid(a(0),2)
End function