Solved

How can I automatically launch a terminal services session when the server boots?

Posted on 2009-05-13
7
541 Views
Last Modified: 2012-05-06
I have a Server running 2003 Server Standard.  It functions primarily as a terminal server, but also runs a background application that needs to be started at system startup and remain running indefinitely.  The background app runs on it's own account in a ts session that is usually disconnected, though I do need to be able to connect to it now and again.
I've tried a number of methods without success:
1. Start the background app using the windows task scheduler.  (This runs the app, but not in a session that I can connect to.)
2. Start an mstsc session using the windows task scheduler.  (After it boots, I can see the mstsc.exe in task manager processes, but the account does not logon on successfully.  Terminal Services Manager shows no sessions other than the console.)
3. Use autoadminlogon to automatically log on an account with a logon script that launches the mstsc session, then logs itself off, leaving the mstsc session active but disconnected.  (This works, except that the defaultusername setting changes as different people log on to the console session, causing the autoadminlogon to fail.)  Strangely the same script that works here does not work if launched by task scheduler.
Any help would be greatly appreciated.
0
Comment
Question by:3mCanada
  • 4
  • 3
7 Comments
 
LVL 51

Assisted Solution

by:Netman66
Netman66 earned 240 total points
ID: 24391112
You should be able to do this like so:

1)  From the Run box, type in mstsc - then ENTER
2)  Click the Options arrow (lower left).
3) Setup the connection with username and password
4) Check the box for Allow me to Save credentials.
5) From the first tab, Save As - save it somewhere you can find it.
6) You can create a batch file using the following syntax:

mstsc.exe Connection.rdp

Where Connection.rdp is the full path to the RDP file you saved above.

7)  Save the .cmd file above to the Administrator's startup folder.  As long as the Administrator logs in this will run.  You may need to configure Autologon and include a way to lock the console afterwards (easy enough).  Do not do this on a DC because the builtin Administrator is also Domain Admin and Enterprise Admin.  You'd rather run this from a member server.

This should launch the TS client using the RDP file for input.

Let us know how you make out.
0
 

Author Comment

by:3mCanada
ID: 24398499
Thank you Hetman66.

This is similar to my #3 attempt, other than firing the cmd file from the startup folder rather than as a logon script.  The problem that arises is that it ties up the console session.  (This server is on an isolated network, so the only outside world connection is the KVM, which of course connects to the console session.  Different people with  different security priviledges need remote access to the server, so I can't tie up that console session.)  I tried putting a logoff in the cmd file, but that just creates an endless loop of logging the console session on and off.  Also, when different people log on to the console session, the defaultusername changes, which of course interferes with AutoAdminLogon.
0
 
LVL 51

Expert Comment

by:Netman66
ID: 24398994
Not sure I follow your logic.

If you're using RDP (mstsc) to the server then the KVM has nothing to do with that.  The only way you'd be on the console is if you're using the -console switch when launching mstsc.


0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:3mCanada
ID: 24399403
Sorry, I'll try to explain better...
Within the building, we're using RDP.  For security reasons, the LAN on which this server resides is isolated.  That is, there is no physical network connection to our office lan, or the internet, or any other external network.  However, we do occasionally need to perform tasks remotely, for which we have a KVM that sits on our regular office lan, allowing limited external access.
The problem is that AutoAdminLogon logs on as the console session, so it is not possible  to connect via the KVM with any credentials other than those of the AutoAdminLogon account.  (Both administrators and non-administrators need occasional KVM access.)
I hope this clarifies my dilemma.
0
 
LVL 51

Expert Comment

by:Netman66
ID: 24400412
What if you were to hook the KVM to an XP workstation on the same segment then logon to it?

From that box, RDP to the server with whatever credentials you need.
0
 

Accepted Solution

by:
3mCanada earned 0 total points
ID: 24434328
That would work, though I'd have to dedicate a machine to it, as all the existing ones are used as process controllers and have logon restrictions.

In any case, I figured out the problem and a work-around.  It appears that if mstsc is launched too soon after booting, the connection attempt is rejected, which is why my attempt to launch mstsc from task scheduler was failing.  (Even launching it from the startup folder of the autoadminlogon account was only intermittently successful.)

I now have task scheduler launching a .cmd file with a 60s delay (ping localhost -n60) prior to the mstsc call, and that seems to work.  If I reduce the delay to around 10s it starts failing again.
0
 
LVL 51

Expert Comment

by:Netman66
ID: 24435772
Okay, thanks for the update.

Glad you got it sorted.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now