• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 557
  • Last Modified:

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

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
3mCanada
Asked:
3mCanada
  • 4
  • 3
2 Solutions
 
Netman66Commented:
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
 
3mCanadaAuthor Commented:
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
 
Netman66Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
3mCanadaAuthor Commented:
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
 
Netman66Commented:
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
 
3mCanadaAuthor Commented:
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
 
Netman66Commented:
Okay, thanks for the update.

Glad you got it sorted.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now