By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,728 Members | 1,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,728 IT Pros & Developers. It's quick & easy.

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

P: 5
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
Share this Question
Share on Google+
8 Replies


Plater
Expert 5K+
P: 7,872
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

P: 5
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
Expert 5K+
P: 7,872
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

P: 5
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
Expert 5K+
P: 7,872
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

P: 5
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
Expert 5K+
P: 7,872
When I run "telnet.exe (some ip address)" it opens and connects for me.
Mar 18 '08 #8

P: 5
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.