Citrix PS4.5 - Script Session Reset w/ Specific Criteria

Posted on 2011-04-27
Last Modified: 2012-06-21
Our environment is currently 5 x Windows 2003 Server Enterprise 32bit servers running Presentation Server 4.5 in a farm.

We have an application that does not close properly when a session is reset, which locks the user in the database the application uses.  The application itself does not have a built-in idle timer, so I can't query it to execute the script I need.  This also throws out the use of Group Policy, as the auto-reset functionality of Terminal Services won't work.  

I need a script (MFCOM / POWERSHELL / VB / Anything) that helps me accomplish the following:

Query farm (or just server) for a list of users by application, username, and idle time

If idle time >= 15 minutes and application =X and username = X, do nothing

If idle time >= 15 minutes and application = X and username = Y, pass the username to a variable that can then be added to the end of a website script we use:

Reset the session tied to this user

I would like to run this script as a scheduled job via Windows Task Scheduler every 5 minutes.  I have a list of users I want this script to work on and a list of users I want to be excluded from it.  If it is easier to create this script per Citrix box, I am open to doing it that way and having each server run their own scheduled task to accomplish the above.

I do NOT have the Powershell or MFCOM SDK installed on these servers, so if you could point me to a resource on how to install/setup whatever coding infrastructure is needed for these scripts to run properly (including what command I need to pass to Windows Task Scheduler in order for the script to execute), I would really appreciate it.

Please let me know if there is any additional information required and I will do my best to get you the detail you need.

Thanks in advance!
Question by:Mathius123

    Expert Comment

    Check out the query user command instead, you can get most of the parameters you are looking for (active/disconnect, idle, userid and session id)  When you find your idle user, that is a valid user on the server you are running the task on, you could validate with query process to validate the specific process, and continue processing from there.  I use a nice tool called autoit for task like these.  You could even wrap the start-up of the application into your script, have a loop that looks for the idle, only publish the wrapped application to the users you are worried about, it starts with the identified user/application, finds idle during loop, breaks loop and processes the rest of your shutdown process.

    Accepted Solution

    I figured it out using MFCOM and VBScript.  If anyone wants a copy of the code I used to accomplish this, please contact me and let me know.

    Author Closing Comment

    I was able to figure it out on my own.
    LVL 7

    Expert Comment

    Mathias, I would like a copy of the script that you put together for this.  I'm having issues with published Lync 2010 and the service continuing to run for idle users.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
    In this previous article (, we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
    How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 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

    21 Experts available now in Live!

    Get 1:1 Help Now