Options

Logon script for terminating an idle application.

albangaalbanga Member Posts: 164
Hello all,

I was wondering if anyone can assist with a little problem i am having. We are currently running an application that is low on licenses. Many times a day we have to send out messages to staff to tell them to log off if they are not using the application. The easiest way to fix this is to obviously buy new licenses. The problem is that we are making this program redundant soon and it is onyl be used at present until the implementation of the new one. So management arent to keen to spend $50,000 on these.

So what i would like to do to make life a little easier for myself and the staff is to run a logon script that sees when an application has been sitting idle for around 30 minutes at which time it will end the process. The problem is that im useless at script writing and cant find anything really solid on the internet to assist.

So what i guess im asking is if anyone knows of a script that could do this? And if so could you please post it so i can copy and make the neccessary changes.

It will need to be a logon script running in a terminal services enviroment, or if there is another way to do it im all ears.

Thanks in advance!

Comments

  • Options
    sprkymrksprkymrk Member Posts: 4,884 ■■■□□□□□□□
    The trick to that one is how to find out if the process is idle. It would be easy just to see if it was running, and if so kill it. Another question I have is this - If the program runs under a "user" context, why does it continue to run once the user logs off?
    All things are possible, only believe.
  • Options
    blargoeblargoe Member Posts: 4,174 ■■■■■■■■■□
    One quick and dirty way that might work: if it runs from a network file share, you can go into the computer management console on the server and kill any open connections to that share or to that .exe depending on your preference.
    IT guy since 12/00

    Recent: 11/2019 - RHCSA (RHEL 7); 2/2019 - Updated VCP to 6.5 (just a few days before VMware discontinued the re-cert policy...)
    Working on: RHCE/Ansible
    Future: Probably continued Red Hat Immersion, Possibly VCAP Design, or maybe a completely different path. Depends on job demands...
  • Options
    albangaalbanga Member Posts: 164
    Sorry should have been clearer.

    When the user logs off it does end the session. The problem is we have users who run this application, they do what they need to do and then they go off on client visits or lunch or whatever really but leave the application opened.

    So it is sitting there open and using a license. I could open terminal services manager and find the idle processe and terminate them but i honestly dont have the time to keep on checking this (who would). So what i was hoping for is a script that sais something like;

    if adapt.exe = idle 60mins "terminate"

    As i said i dont write scripts as you can see but hopefully you understand what i am saying. Maybe you wouldnt even run the login script on the users profile perhaps you could run it as a logon script on each terminal server.

    Like i said im really in the dark on this one and was hoping someone might have had a similar problem. As sprkymrk said i think the key is to find out the idle process and eliminate it.
  • Options
    Darthn3ssDarthn3ss Member Posts: 1,096
    not related to logon scripts but tell the users that management has informed you that if you can not get this licensing problem fixed they will take cost by eliminating paid vacations for all employees who have been working for the company for less than 12 years.
    Fantastic. The project manager is inspired.

    In Progress: 70-640, 70-685
  • Options
    sprkymrksprkymrk Member Posts: 4,884 ■■■□□□□□□□
    What is the program you want to kill, a custom app?
    How do you, as an admin, see that it is idle?
    Does the process run on the client or terminal server?
    All things are possible, only believe.
  • Options
    JDMurrayJDMurray Admin Posts: 13,034 Admin
    I don't believe that the 32-bit Windows OS has the concept of "process idle time" like UNIX does. I've been looking through all of the information displayed by the Process Explorer and Process Monitor utilities from www.sysinternals.com and I don't see anything that indicates states such as "active" and "idle" or "idle time."

    From a software point of view, the program could expose an API which allows another process run from a script to query the program as to when the user last interacted with it. If no such API exists, then I would write a monitor program which launches the first program as a child process and watches it for user mouse and keyboard input. After a specific period of time has passed where no user input has been received, the monitor program will kill the child process. It seems reasonable to think that such utility programs are already available.
  • Options
    AhriakinAhriakin Member Posts: 1,799 ■■■■■■■■□□
    Still requires coding but you could generate a kind of screensaver that blanks the screen but also kills that process if it exists, set it through Policy (or whatever) as the default screensaver for whatever idle time you wish. This has windows is using it's own idle/screensaver timer to schedule the process-kill.
    We responded to the Year 2000 issue with "Y2K" solutions...isn't this the kind of thinking that got us into trouble in the first place?
  • Options
    blargoeblargoe Member Posts: 4,174 ■■■■■■■■■□
    If it's running under Terminal Server, you can log on the server and go into Terminal Services Configuration under administrative tools. From there you can easily set an idle timeout period for the connection. As long as tell it to log off and not simply disconnect after the idle period, it will close the application and the user will be logged off.
    IT guy since 12/00

    Recent: 11/2019 - RHCSA (RHEL 7); 2/2019 - Updated VCP to 6.5 (just a few days before VMware discontinued the re-cert policy...)
    Working on: RHCE/Ansible
    Future: Probably continued Red Hat Immersion, Possibly VCAP Design, or maybe a completely different path. Depends on job demands...
Sign In or Register to comment.