consider something like this (it looks for an ipaddress in a shape data
field called 'compIpAddress'
al
'
' open a terminal services session from a winshell to the remote
'
Public Sub TermServeToTarget(ByRef visWin As Visio.Window, _
ByVal strShape As String)
On Error GoTo ErrHandler
Dim visPage As Visio.Page
Dim visShapes As Visio.Shapes
Dim visShape As Visio.Shape
Dim visCell As Visio.Cell
Dim shellWin As Object ' create a variable for the script shell
Dim strCommand As String
strCommand = "c:\windows\system32\mstsc.exe /v:"
Set visPage = visWin.Page
Set visShapes = visPage.Shapes
Set visShape = visShapes.Item(strShape)
' if there get ip address if not get out
If visShape.CellExists("prop.compIpAddress", False)
Then
Set visCell =
visShape.Cells("prop.compIpAddress")
strCommand = strCommand & visCell.ResultStr("")
' have to change the /console to /admin to
support srv2008
' should work for everyone else as well
strCommand = strCommand & " /admin"
Else
MsgBox ("couldn’t find compIpAddress custom
property")
Exit Sub
End If
' create the script shell environment
Set shellWin = CreateObject("wscript.shell")
' now execute the command that we built
shellWin.Run (strCommand)
Exit Sub
ErrHandler:
Debug.Print "Terminal server " & Err.Description
End Sub