Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - "Shellexecute" telnet

Reply
 
Old 06-15-2008   #1 (permalink)
Kryten


 
 

"Shellexecute" telnet

Hi,

In my script I'm grabbing the contents of a textbox, that contains a
hostname and calling it $a.
I want to give the user a couple of options with this.

Remote desktop to console session:-
$i = $textbox1.text; if ($i -ne "") { Invoke-Expression "mstsc /v:$i /
console" }
works just great. As does ping to the $i host.

So I thought I could:-
$i = $testbox1.text ; if ($i-ne "") { Invoke-Expression "Telnet $i" }
But from what I can see the telnet window spawns then closes
immediately.
I vaguely remember something about -noexit parameters but can quite
put my finger on the
syntax used or if that's the right approach?

The closest I can get is:-
$i = $testbox1.text ; if ($i-ne "") { Invoke-Item "C:\Windows
\System32\Telnet.exe" }
Which launches telnet fine but I can't seem to find any way to pass
along the $i hostname.

Or is there a better way to kick off a Telnet session to a string
variable datatype?

Any advice appreciated as always.

Thanks,

Stuart

My System SpecsSystem Spec
Old 06-15-2008   #2 (permalink)
Shay Levi


 
 

Re: "Shellexecute" telnet

Hi Kryten,


if ($i -ne "") { & cmd.exe /K telnet $i 80}

/K - Carries out the command specified by string but remains
/C - Carries out the command specified by string and then terminates

Make sure to pass a port number to telnet as the default port number is 23.


---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com

K> Hi,
K>
K> In my script I'm grabbing the contents of a textbox, that contains a
K> hostname and calling it $a.
K> I want to give the user a couple of options with this.
K> Remote desktop to console session:-
K> $i = $textbox1.text; if ($i -ne "") { Invoke-Expression "mstsc /v:$i
K> /
K> console" }
K> works just great. As does ping to the $i host.
K> So I thought I could:-
K> $i = $testbox1.text ; if ($i-ne "") { Invoke-Expression "Telnet $i"
K> }
K> But from what I can see the telnet window spawns then closes
K> immediately.
K> I vaguely remember something about -noexit parameters but can quite
K> put my finger on the
K> syntax used or if that's the right approach?
K> The closest I can get is:-
K> $i = $testbox1.text ; if ($i-ne "") { Invoke-Item "C:\Windows
K> \System32\Telnet.exe" }
K> Which launches telnet fine but I can't seem to find any way to pass
K> along the $i hostname.
K> Or is there a better way to kick off a Telnet session to a string
K> variable datatype?
K>
K> Any advice appreciated as always.
K>
K> Thanks,
K>
K> Stuart
K>


My System SpecsSystem Spec
Old 06-15-2008   #3 (permalink)
Kryten


 
 

Re: "Shellexecute" telnet

Thanks Shay, that does work from the ps command line but for some
reason
my app didn't like it causing it to go 'not responding'. Weird.

I settled on:-

{ $tel = $textbox1.text;
$f = New-Object -com wscript.shell
$f.run("Telnet.exe $tel")
}

Thanks!

Stuart

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Unwanted Multiple contacts in "To","CC","BCC" of email send catago Vista mail
cygwin fails on Vista and Win Enterprise only, telnet "switching to user andy failed" Vista security
Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" Vista General
How can I add the icons "Delete", "Cut", "Copy" and "Paste" in Vis Vista file management
WM5 Sync with Vista "Windows Calender", "Contacts", and "Mail" Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46