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!

Launching Terminal Services from IE 1

Status
Not open for further replies.

MyNameIsTom

Technical User
Jan 8, 2004
4
0
0
US
I have hit a lot of dead ends trying to launch a Terminal Services session from Internet Explorer. I cannot use a component or TSweb to do this because of the environment I work in. Basically, I need to pass an IP address to the script, which will launch a separate TS session.

Thanks!
 
You could do something akin to this:

<script language=vbscript>
function ts_connect()
set sh = createobject(&quot;wscript.shell&quot;)
sh.run &quot;%systemroot%\system32\mstsc.exe /v:&quot; & data.ip.value
set sh = nothing
end function
</script>
<form name=data>
IP/System to connect to:<BR>
<input type=text name=ip size=15><BR><BR>
<input type=button value='Connect' onclick=&quot;vbscript:if data.ip.value = '' then msgbox('You need to specify a server!') else ts_connect()&quot;>
 
Thanks, Strahan. That is exactly what I need.

The only problem is that the command-line argument &quot;/v:&quot; to start a session on that IP/host only works for the Remote Desktop Client, not the Terminal Services client.

Does anyone know if the Terminal Services client supports a command-line argument?

Thanks again.
 
AFAIK, the same client is used for both environments since they are the same thing. Just different versions.

The Remote Desktop Client is simply mstsc.exe version 5.1 and can connect to any Terminal Services host.

Since I can't find anything on command-line switches for older versions, is there some reason not to download and use the 5.1 client with your Terminal Server(s)? In 5.1 there is a /migrate switch to pick up old client Connection Manager connection files if need be.
 
I work in a highly controlled environment where you cannot install unapproved software. Even though we all know that the newer client is probably only more secure, I cannot simply use the newer version. It has to be tested, approved, rolled out .... You get the idea!

Thanks.
 
Oh yeah. Been there, done that.

Funny thing is (it's a big org here) I keep asking &quot;Then where is the approval test lab? What's the approval process? What are the criteria for approval? Who can I talk to about this?&quot; etc.

Dead silence.

Then these johnnies have Slammer run rampant last summer because they're too {insert excuse here} to deploy the fixes that had been out for weeks.

My own opinion is that the mechanics and menials are running IT in many organizations these days. Their goal is to avoid any effort. I suspect insecurity (&quot;Emperor's New Clothes&quot;) is behind much of it rather than laziness. The only way I can get anything my users need is when it's tied to some high-visibility project (and/or I can get some consultant to bring it up).

In your case you'd probably need asssitance with large-scale deployment even if you could get away with installing something like the newer RDP client. Leaves you high and dry I guess.

Sorry I can't help more.
 
I was looking for this and glad I found it. I really could use this. Just for kicks I dumped it into a test.htm file and clicked it. When I hit the connect button (after entering in an IP address), IE indicates an error

Line: 12
Char: 73
Error: Type mismatch: 'ts_connect'
Code: 0
URL: file//C:\test2.htm

and the line in question is (all one line)

<input type=button value='Connect' onclick=&quot;vbscript:if data.ip.value = '' then msgbox('You need to specify a server!') else ts_connect()&quot;>

This would actually be a life saver. We are going to have a lot of servers that we will need to connect to using TS and I am going to try and use a PHP frontend to MySQL to help us connect to them. At the same time....I get to learn it. Wish me luck and thanks for the help.
 
Try either this:
Code:
<input type=button value='Connect' onclick=&quot;vbscript:if data.ip.value = '' then msgbox('You need to specify a server!') else ts_connect&quot;>
or this:
Code:
<input type=button value='Connect' onclick=&quot;vbscript:if data.ip.value = '' then msgbox('You need to specify a server!') else call ts_connect()&quot;>


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
If anyone can find out how to call the older Terminal Services client (Win2K) with command line arguments I sure would appreciate it. This trick only seems to work with the newer Remote Desktop client.

Thanks.
 
We actually only utilize Citrix ICA onsite, but here's what I what I recall about MSTSC.

As you've realized, this is no issue with RDP5.1 because you can use command line parameters or a connection file.

However, RDP5 only has 1 command line parameter, the name of a connection as defined in Client Connection Manager. Also adding to the mix, in RDP5, MSTSC doesnt install to the System32 folder, it defaults to the Program Files but the user can install where they see fit.

You can get the exe path by looking to the Uninstall script.

set oShell = createobject(&quot;wscript.shell&quot;)
strPath = oShell.RegRead(&quot;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Terminal Server Client\UninstallString&quot;)
strPath = Replace(strPath,&quot;setup\Setup.exe&quot;,&quot;mstsc.exe&quot;)

You can either use &quot;user-emulation&quot; aka Sendkeys.

oShell.Run chr(34) &amp; strPath &amp; chr(34), 1
oShell.Popup &quot;Launching Terminal Services Client....&quot;,1,&quot;Please Wait&quot;
oShell.AppActivate &quot;Terminal Services Client&quot;
oShell.Sendkeys &quot;ServerIPorName~&quot;

Inject the Client Connection Manager connection config via the registry and use it on the command line.

strKey = &quot;HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\MyServer\&quot;
oShell.RegWrite strKey &amp; &quot;Auto Connect&quot;,1,&quot;REG_DWORD&quot;
oShell.RegWrite strKey &amp; &quot;MRU0&quot;,&quot;10.10.10.10&quot;,&quot;REG_SZ&quot;
oShell.Run chr(34) &amp; strPath &amp; chr(34) &amp; &quot; MyServer&quot;

Jon Hawkins
 
The Terminal client that comes with XP is so much better and you don't actually have to install it via a setup. Not sure how big a corner you are in, but just to let you know, you can take the mstsc.exe and copy it over (or rename the original and then copy it in) the one that is installed via the client setup. This then updates it on the spot. No setup or install.
 
I am trying to put this script into a php web page and passing the ipaddress to it with a variable named $result. With the script above....how can I just call the function without all the input? Or...is there an eassier way. I can pass the IP address via the url....can I use this to pass it to the vbscript without using php? Such as

Or whatever the page name needs to be if not .php.

Thanks for any help....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top