468,758 Members | 2,081 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,758 developers. It's quick & easy.

how do i telnet to an ip address from vb.net code

Hi guys im trying to telnet to an IP address that is entered into a textbox from the click of a button but im having problems as it just gives me errors when i run it. Here is my code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnTelnet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTelnet.Click
  2.  Dim telnet As Process = New Process
  3.         telnet.StartInfo.FileName = "telnet.exe"
  4.         telnet.StartInfo.Arguments = "o" + txthostname.text
  5.         telnet.StartInfo.WindowStyle = ProcessWindowStyle.Normal
  6.         telnet.StartInfo.CreateNoWindow = True
  7.         telnet.Start()
  8.     End Sub 
  9.  
without the "telnet.StartInfo.Arguments = "o" + txthostname.text" command it just opens telnet but with the code it says "unexpected error continue or quit".

Any help would be great
Cheers
Mar 17 '08 #1
8 5496
Plater
7,872 Expert 4TB
Well uh, what are you trying to do?
I don't see you capturing the input/output/error streams, but you tell it to NOT create a window.
Mar 18 '08 #2
Well uh, what are you trying to do?
I don't see you capturing the input/output/error streams, but you tell it to NOT create a window.
Hi mate, thanks for the reply.

What im trying to do is enter an ethernet ip address into a textbox then click the "telnet button" which opens up microsoft telent command prompt and automatically enters in the IP address that was entered in to the text box and telnets to the interface...this is so basically the user doesnt need to enter a IP address when telnet opens.

Does anyone know how to do this in code?
Thanks in advance
Mar 18 '08 #3
Plater
7,872 Expert 4TB
Well if that is the case, be sure to remove this line:
telnet.StartInfo.CreateNoWindow = True

so a window will popup for the user to see.
Mar 18 '08 #4
Well if that is the case, be sure to remove this line:
telnet.StartInfo.CreateNoWindow = True

so a window will popup for the user to see.
Thanks for the advice but still doesnt work. Is there anyway to send arguments to the telnet session once opened?

Cheers
Mar 18 '08 #5
Plater
7,872 Expert 4TB
I just noticed that you are adding that "o" in there, whereas telnet does not take such arguments.
Try
Expand|Select|Wrap|Line Numbers
  1. telnet.StartInfo.FileName = "telnet.exe"
  2. telnet.StartInfo.Arguments = txthostname.text
  3.  
Mar 18 '08 #6
I just noticed that you are adding that "o" in there, whereas telnet does not take such arguments.
Try
Expand|Select|Wrap|Line Numbers
  1. telnet.StartInfo.FileName = "telnet.exe"
  2. telnet.StartInfo.Arguments = txthostname.text
  3.  
Tried this and it opens Telnet but doesnt enter the txthostname.txt argument for me :(

thought the "o" stood for open that why i did that.
Cheers again
Mar 18 '08 #7
Plater
7,872 Expert 4TB
When I run "telnet.exe (some ip address)" it opens and connects for me.
Mar 18 '08 #8
Sorry mate its my fault was entering an IP address in the wrong text box lmao..DOH!

Works a treat thank you very much
Mar 18 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by G520 | last post: by
4 posts views Thread by Donnal Walter | last post: by
reply views Thread by CJ | last post: by
2 posts views Thread by _andrea.l | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.