none
how to make task scheduler do a task when user log off RRS feed

  • Question

  • Hi, I hope the title says it all. In task scheduler you have trigger option such as
    1. On a schedule
    2. At log on
    3. At startup
    4. On idle
    5. On an event
    6. At task creation/modification
    7. On connection to user session
    8. On disconnect from user session
    9. On workstation lock
    10. On workstation unlock

    I am looking for trigger option that allow me to do task on user logoff/reboot/shutdown. I have tried "On disconnect from user session", and it did not work.

    Anyone has any ideas?
    • Moved by Carey FrischMVP, Moderator Sunday, November 15, 2009 11:19 PM Moved to relevant category (From:Windows 7 Miscellaneous)
    Saturday, November 14, 2009 12:55 PM

Answers

All replies

  • Set a logoff script in local or group policy?
    Sunday, November 15, 2009 10:46 PM
  • Please see the following articles:

    Startup, shutdown, logon, and logoff scripts 

    Assign user logoff scripts 


    Arthur Xie - MSFT
    Tuesday, November 17, 2009 8:59 AM
    Moderator
  • it's for local policy, it's Win 7 Professional, but it's home computer.
    Tuesday, November 17, 2009 7:04 PM
  • Thanx, I just tried that. The problem with script is that I can't interact with the program I need to run before logout. This is why I prefer task scheduler. If there is no other way, I guess I have to learn PowerShell script, and see if I can auto the whole task.
    Tuesday, November 17, 2009 7:54 PM
  • Hi cocao117, one of the many irratations with Windows 7 is trying to do just what you are now. In the old days, you could run an interactive task as system or another user and the currently logged on user would see and be able to interact with it. This was useful for many, many reasons.

    Now, you just can't run an interactive task like this, at least, not without possibly using some very extreme (and possible dodgy) techniques. I have had to do some crazy things on our Windows 7 builds to get around this, thank you, Microsoft.

    Here is my example:

    1. We have a nightly shutdown task that runs interactively as system. The task shows a shutdown dialogue to the user and they can cancel, pause or ok, etc, the shutdown.

    2. On Windows 7, this does not work. After several days on and off trying to get this to work, what I had to do was if another exe is running, that is launched under the user context when they logon, the shutdown task creates a text file and exits. The other task, running as the user, sees this and re-reruns the shutdown task under the user context. They then can see it and interact with it. luckily, they still have the rights to shutdown the PC programmatically otherwise I would be buggered.

    I know this does not help you, cocao117, but, hopefully, someone in Microsoft might release that changing things like this, without giving administrators an over-ride, is very problematic.
    Tuesday, November 17, 2009 9:09 PM
  • Session 0 isolation, introduced with Vista, was meant to eliminate a security risk caused by running services and user applications together in the same session.  So interactive services are not a desirable way of doing things in Vista+.

    We have a nightly shutdown task that runs interactively as system. The task shows a shutdown dialogue to the user and they can cancel, pause or ok, etc, the shutdown.
    That sounds like PsShutdown, or something like it... :-)
    Thursday, November 19, 2009 3:39 AM
  • I know this was done for security reasons. However, as I have mentioned in other threads, as the system administrator of our domain, I want to be able to do this. I should be able to do this. I acknowledge the security risk but I should be able to over-ride such enforced changes and make this work. For example, UAC is a new security feature in Vista+, you can turn that off. The new task scheduler in Vista+ is excellent with many more features, but you can't do this basic thing any more.

    Oh, our shutdown task is an in-house .NET exe. I had to specially create it so that all of our user needs and complaints regarding nightly shutdowns were addressed :)

    Thursday, November 19, 2009 6:57 PM
  • Seems like you've now got something similar to it, but you could architect the app so that the interactive component would run in the session of the user(s), and would communicate with the service through some IPC mechanism...

    UAC's primary goal is to get more people to run as standard users - it's not meant to be a hard security boundary. 
    Friday, November 20, 2009 3:10 AM
  • Seems like you've now got something similar to it, but you could architect the app so that the interactive component would run in the session of the user(s), and would communicate with the service through some IPC mechanism...
    Yes, I could, I'm actually a good programmer, there's all sorts of ways I could improve this, but this was quickest and already in place and I couldn't be bothered to spend more time on it...

    UAC's primary goal is to get more people to run as standard users - it's not meant to be a hard security boundary. 

    It was just an example...
    Friday, November 20, 2009 4:24 AM
  • I'm trying to do this too.  My script isn't interactive, but needs to be run as admin.  The group policy logoff script runs as the current user.  Is 'On disconnect from user session' not the same as 'On logoff' in Task Scheduler?

     

    Thursday, January 20, 2011 10:24 PM