Use TAPI to make a call programatically using vb script
Hope someone finds it useful. Its a vb script I threw together to make calls via TAPI.
Interestingly enough on a Terminal Server any user can make use of any of the TAPI addresses registered on the server unless they are specifically linked to a user. You can do this via tapimgmt.msc
Save the below in a txt file and rename it to dial.vbs
Hope someone finds it useful. Its a vb script I threw together to make calls via TAPI.
Interestingly enough on a Terminal Server any user can make use of any of the TAPI addresses registered on the server unless they are specifically linked to a user. You can do this via tapimgmt.msc
Save the below in a txt file and rename it to dial.vbs
Code:
Option Explicit Dim strFilter, strNumber strFilter = "" If (Wscript.Arguments.Count < 1) Then Wscript.Echo "Make a call via TAPI" & vbcrlf & vbcrlf & "dial.vbs Number StringToSearchForInTapi" Wscript.Quit Else ' Retrieve the first argument (index 0). strNumber = Wscript.Arguments(0) If Wscript.Arguments.Count > 1 Then ' Retrieve the second argument. strFilter = Wscript.Arguments(1) End If End If If Wscript.Arguments(0) = "-list" Then Call ListTAPI() Else Call MakeCall(strNumber, strFilter) End If Sub MakeCall(strNumber, strFilter) Dim lAddressType, objTapi, objCollAddresses, objCrtAddress, lLoop, NewCall, gobjAddress Const LINEADDRESSTYPE_PHONENUMBER = 1 Const LINEMEDIAMODE_INTERACTIVEVOICE = 4 lAddressType = LINEADDRESSTYPE_PHONENUMBER Set objTapi = CreateObject("TAPI.TAPI.1") objTapi.Initialize Set objCollAddresses = objTapi.Addresses For lLoop = 1 To objCollAddresses.Count Set objCrtAddress = objCollAddresses.Item(lLoop) If Instr(objCrtAddress.AddressName, "IP Phone:") > 0 Then If Instr(objCrtAddress.AddressName, strFilter) Then Set gobjAddress = objCrtAddress Exit For End If End If If lLoop = objCollAddresses.Count Then Msgbox "TAPI Provider Not Found" WScript.quit(-1) End If Next Set NewCall = gobjAddress.CreateCall(strNumber, lAddressType, LINEMEDIAMODE_INTERACTIVEVOICE) ',lMediaTypes)'Set NewCall.connect(False) End Sub Sub ListTAPI() Dim strAddressList, lAddressType, objTapi, objCollAddresses, objCrtAddress, lLoop Const LINEADDRESSTYPE_PHONENUMBER = 1 lAddressType = LINEADDRESSTYPE_PHONENUMBER Set objTapi = CreateObject("TAPI.TAPI.1") objTapi.Initialize Set objCollAddresses = objTapi.Addresses For lLoop = 1 To objCollAddresses.Count Set objCrtAddress = objCollAddresses.Item(lLoop) strAddressList = strAddressList & objCrtAddress.AddressName & vbCrLf Next Wscript.echo strAddressList End Sub
Comment