Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Telnet button, read field, auto user/PW response

Status
Not open for further replies.

Emblem1

Technical User
Jan 11, 2007
77
0
0
US
Hello.

I have a form in which there is a field called 'IP_address'. I would like to create a button on the form that will launch 'telnet' to the address in the 'IP_adress' field for the 'on click' event. Also, the telnet session will get promted by the device it is connecting to for a 'user' and 'password'. All devices in which I am connecting to will require the same responses. Is there a way I can integrate this as well? I have no idea how to assemble the vba code.

Thanks.
 
A starting point:
CreateObject(WScript.Shell).Run "telnet " & Me!IP_address

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I get a runtime error '424', object required. ?? I pasted the code as this:

Private Sub cmdTelnet_Click()
CreateObject(WScript.Shell).Run "telnet " & Me!IP_Addr
End Sub

Thanks.
 
Sorry for the typo:
CreateObject([!]"[/!]WScript.Shell[!]"[/!]).Run "telnet " & Me!IP_Addr

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OK, it seems to work, but the command window closes as soon as it opens. I am guessing there needs to be additional commands to keep it running after finishing the commands?

Thanks.
 
The issue was that the IP was being handled wrong before using it with telnet. So to make this work better, I broke up the IP octets into individual fields on the form/table. I was then able to make IP address cleaner before submiting to the telnet command.

I also used an input mask of !099;;_ for each octet field.

The code:

Private Sub cmdTelnet_Click()
Dim a As String '1st octet
Dim b As String '2nd octet
Dim c As String '3rd octet
Dim d As String '4th octet
Dim e As String 'entire IP address

a = Trim(Me.IP_1.Value)
b = Trim(Me.IP_2.Value)
c = Trim(Me.IP_3.Value)
d = Trim(Me.IP_4.Value)

e = a & "." & b & "." & c & "." & d

CreateObject("WScript.Shell").Run "telnet " & e

End Sub

Simple and effective.

Thanks again PHV!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top