Solved

Running a script for a TS user

Posted on 2010-08-13
6
757 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
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…

773 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