Solved

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

Posted on 2009-05-13
7
545 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Organizations create, modify, and maintain huge amounts of data to help their businesses earn money and generally function.  Typically every network user within an organization has a bit of disk space to store in process items and personal files.   …
Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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