Solved

Running a script for a TS user

Posted on 2010-08-13
6
760 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
[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
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change Exchange 2010 Namespace 6 71
User Folder Creation and Permissions 3 47
Active Directory Powershell Script 9 41
Moving database to a shared server 7 29
Learn about cloud computing and its benefits for small business owners.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
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…

739 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