create custom property to run remote control

A

ApostolisA

I have a network diagram and i want to create a custom property for remote
control.
I this valid with visio and how?

Thanks.
 
A

Al Edlund

Custom Properties are good for what the name implies, adding something
specific to a shape like an address or a network unique name.
The actual connectivity behind what you are asking for requires that you
write code. There are a couple of things that play into this: Availablility,
Installation, Configuration, Initialization (but I digress). The two most
common MS means are to either Telnet or use Terminal Services Clients. Here
are two examples. The first one uses a hyperlink to telnet to a device using
a custom property which is initalized to the IP Address of the remote
device. The second one creates a scriptshell and then executes the Terminal
Services Client code (MSTSC) to open a desktop session.

' for things with an ip address we will add a hyperlink that will tie itself
to the

' ip address and allow the user to telnet to the device (assumes the device
will

' accept the session)



' In the add routine for hyperlink we test that a shape section exists

' before we add the link now add the basic hyperlink row



Public Sub AddTelnetHyperlink(byval strShape as visio.shape)

blnPropAdded = AddHyperLinkToShape(visShape, "CallTelnet")

DoEvents

' normally we would just do this with the above call, but we want to
add

' the name of another cell with the formula so we'll do it here

If visShape.CellExists("hyperlink.calltelnet.address", False) Then

Set visCell = visShape.Cells("hyperlink.calltelnet.address")

visCell.FormulaU = """TELNET:""&Prop.Ipaddress"

Set visCell = visShape.Cells("hyperlink.calltelnet.description")

visCell.FormulaU = """TELNET:""&Prop.Ipaddress"

End If

End sub





' We may want to work with something that supports terminal services



Public sub TermServeToTarget(byval visShape as visio.shape)



Dim visCell As Visio.Cell

Dim wsh ' create a variable for the script shell

Dim strCommand as string



strCommand = ""c:\windows\system32\mstsc.exe /v:"



if visShape.CellExists("prop.IpAddress",False) then

Set visCell = visShape.Cells("prop.IpAddress")

strCommand = strCommand & visCell.Value

strCommand = strCommand & " /console"

else

exit sub

end if



Set wsh = CreateObject("wscript.shell")



wsh.Run (strCommand)



End Sub
 
C

cynthia

I would like to be able to open a telnet session by clicking on a visio shape
after publishing it to the web. I have tried entering "telnet://ipaddress" in
the insert hyperlink dialogue box. It does not work. I am using Visio 2007 in
Vista. I don't understand your explanation, I don't know where to insert this
code for starters! I am a first year student.
Thanks.
 
A

AlEdlund

Vista (with IE7) brings it's own challanges. The two of them have teamed up
to tighten up on security. This means that some of the previous techniques
of faking out an IE call with things like the telnet command may not work
anymore..
check this out
http://www.cisconet.com/index.php/Network-App/Enable-Telnet-on-IE7.0-with-Windows-XP-and-Vista.html

To add to this dilema the customary response of wrapping a command in a
shell script can also lead to issues on an x64 machine. This is due to the
attempt by MS to support both x32 and x64 programs on the same system. In
short if the program you want (such as Telnet) doesn't have both images you
can be in trouble. I use the following code to call telnet (after copying
the telnet exe file from the windows 32 directory to the 64bit directory
(that's also not a support fix)).

al

'
'
'
Public Sub TelnetToTarget(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
Dim strCommand As String
strCommand = "c:\windows\system32\telnet "

Set visPage = visWin.Page
Set visShapes = visPage.Shapes
Set visShape = visShapes.Item(strShape)
' can we determine the rules appropriate
' 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("")
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
'Debug.Print "shellwin start"
DoEvents
shellWin.Run strCommand
DoEvents
Exit Sub
ShellCommand:
'Debug.Print "shell start"
Shell strCommand, vbNormalFocus
'Debug.Print "shell start"
DoEvents
Exit Sub
ErrHandler:
Dim myErr As ErrObject
Set myErr = Err

If Err.Number = -2147024894 Then
Debug.Print "shellwin failed"
GoTo ShellCommand
End If

Debug.Print "telnet " & Err.Description


End Sub
 
C

cynthia

I downloaded the patch from cisconet. Now, I still don't know where to put
that code. Also, we are using 32 bit OSs. I did get some new error messages.
Thanks
 
A

AlEdlund

this code is all vba which is called from an event handler in my drawings.
It can be modified to be called from a macro.
al
 
C

cynthia

I have found lots of information, but nothing that explicitly tells me where
to put this code in the vbeditor. I don't know how to link it to the shape in
my diagram. I have a vague understanding of shape objects. I now know how to
insert a new procedure. That's where I put your code. Now how do I link it to
my shape. I have only used vba in access before and they make it easy through
custom properties.
 
A

AlEdlund

Given this description " would like to be able to open a telnet session by
clicking on a visio shape
after publishing it to the web. " It sounds like you're attempting to pull
this off from a browser. That is a code behind implementation and not done
inside of visio. What you should be considering is during a postback from
the browser kicking off (probably) a scripted function on the server. Is
this closer to what you're trying to do?
al
 
C

cynthia

Right. I want to be able to click on my shape after publishing it to the web
and have the option of opening a telnet session with my shape's ip address.
Thanks for clarifying that.
 
C

cynthia

So would that be something like opening the visio web page html code in an
html editor and adding some kind of java script to it?
 
A

AlEdlund

exactly. the demo code I sent to you is a general type of function to
kickoff a telnet session via a script. although it is in vba you should be
able to use vbscript.
al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top