PASSPORT Knowledge Base
Macros

Date Published: April 28, 2009
Date Published: April 7, 2010

Title

Using a VBscript to execute a PASSPORT macro

Product

PASSPORT PC to Host, PASSPORT Web to Host

Emulation Types

TN3270, TN5250, VT, SCO ANSI, Wyse 60

Issue

I am trying to write a VBscript that will execute a PASSPORT macro.  How can this be done?

Solution

  1. The Session_NavigateTo function below can be used to execute a .ZAM macro:

Dim Sys, Sess
Set Sys = CreateObject("PASSPORT.System")
' Assumes one or more open sessions:
Set Sess = Sys.ActiveSession
' Assume there is MyLoginMacro.zam macro file:
x = MsgBox ("Run login macro?", 1)
If x = 1 Then 
    Sess.NAvigateTo "MyLoginMacro"
End If

Replace "MyLoginMacro" with the name of the macro that you are trying to execute. Make sure when you are running the macro from the command prompt, you enter the correct path where the VBScript file and macro are located. For example, if both the VBScript file and the macro are placed into the PASSPORT application folder (C:\Program Files\PASSPORT\ by default), then the command will look like this:

 

wscript C:\Program Files\PASSPORT\ExecuteMacro.vbs
 

  1. Below is a sample VBScript that is used to execute a .ZMC PASSPORT macro. This script assumes a single, connected PASSPORT session. If more than one session is connected when the script is run, it will run the specified macro on the session that was connected first:

Set objShell = CreateObject("WScript.Shell") 
Set objExec = objShell.Exec("C:\Program Files\PASSPORT\PassMacr.exe /A 1234 0 login.zmc")

Replace "login.zmc" with the name of the macro that you are trying to execute. Make sure when you are running the macro from the command prompt, you enter the correct path where the VBScript file and macro are located. For example, if both the VBScript file and the macro are placed into the PASSPORT application folder (C:\Program Files\PASSPORT\ by default), then the command will look like this:

 

wscript C:\Program Files\PASSPORT\ExecuteMacro.vbs

 

More Information

Keywords

vb, script, vbscript, execute, invoke, passmacr.exe, .exe, macro