Solved

Running a script for a TS user

Posted on 2010-08-13
6
756 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

863 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

22 Experts available now in Live!

Get 1:1 Help Now