Solved

Running a script for a TS user

Posted on 2010-08-13
6
759 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
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 locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

820 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