Solved

Running a script for a TS user

Posted on 2010-08-13
6
755 Views
Last Modified: 2012-08-14
Goal:  When a user logs onto Terminal server, I want a program to run MAXIMIZED.  When they exit the program, I want the user to be logged off.

I have created a batch file that I can run by specifying it in the environment tab in the Configuration>Local Users and Groups>Users found in the server manager.  The problem is that the batch program opens a command window, then opens the specified program window in a NON maximized window.  I can manually maximize it, and I'm good to go, but I don't want the users to do that.  Exiting the program allows the batch to continue and does the logoff correctly.

I have learning about the powershell and scripting.  My problem using that tool is getting the logoff portion of the script to only execute after the program part has run and done a normal exit.  I also suspect that I need to do something about signing to get the script to run.

It seems like I need to go to a lot of trouble to do something that was automatic in Windows Server 2000.
0
Comment
Question by:rdelossa
  • 4
6 Comments
 
LVL 8

Assisted Solution

by:SylvainDrapeau
SylvainDrapeau earned 250 total points
ID: 33434750
Hello !

In your batch file, start your app using START /WAIT /MAX and put the log off command after that.

It will start your app maximized, wait for it to exit and them launch your log off command.

Syldra
0
 
LVL 31

Assisted Solution

by:Henrik Johansson
Henrik Johansson earned 250 total points
ID: 33447225
Not necessary to use logon script as the functionality is builtin into the system to be able to launch a single application on logon and automatically log off the user when application exits.
You can either do it directly on the user object in AD (user properties -> Environment) or with the following policy setting in a GPO and link GPO to OU containing the user object.

User Configuration\Administrative Templates\Windows Components\Terminal Services\Start a program on connection
0
 

Author Comment

by:rdelossa
ID: 33456433
Sylvain,
Thank you for your suggestion.  So far, I have not been able to get the batch to do what I want.  It will not wait when using the START command.   There is a note in the HELP START -START which states:

"When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt.  This new behavior does NOT occur if executing within a command script."

I interpret that to mean I can do it in scirpt (which I have done and does work), but not in a batch.  My issue becomes signing a script....

The batch does wait as a simple batch but the window sizes are confusing to my users.  My script works as a PS command but invoking through the environment tab is another story.

0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

Author Comment

by:rdelossa
ID: 33456486
Henjoh,
Your suggestion is the way it should work and does work on Win 2000 Server.  I can NOT  get it to work in Server 2008.   The logoff does not occur until 2-3 minutes after the user exits the application (which means he has to minimize the RDP window to see his desktop, which is something I'd rather not have him have to do.   I posted a question on this over a month ago and didn't find a solution except writing a script to do it, which now requires that I digitally sign the script to be able to get it to run from the environment tab.  This seems like an awful lot of work, and since I'm a newbe, I thought it must be my own lack of knowledge.
0
 

Accepted Solution

by:
rdelossa earned 0 total points
ID: 33456536
All that are interested:
I have successfully written a script that will wait and logoff correctly when executed from within the powershell.  When I call the script from the User Environment tab, it aborts.  I think this is due to security signing issues.  Is there a way of allowing scripts to be run on a "per user" basis even if the script is not signed?
0
 

Author Closing Comment

by:rdelossa
ID: 34026915
I didn't solve this issue.  
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

I work for a company that primarily works with small businesses as their outsourced IT vendor. As such the majority of these customers utilize some version of Small Business Server. Due to the economics of running a small business, many of these cus…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

747 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

11 Experts available now in Live!

Get 1:1 Help Now