Run a program before Logoff and wait for finish












2














When I want to run a program (.exe .bat) before Windows 7 Home Premium Logoff Restart I use the Task Scheduler and I set a custom event: Log: System, Source: Winlogon, Event ID: 7002 4634 4647 .....



The problem is that the program starts but the system closes before the program finishes, while it's running.



What can I do? (My O.S doesn't have gpedit.msc unfortunately)










share|improve this question
























  • Perhaps give this a try (not sure if it'll work): Add shutdown /a to the start of the script (to abort the current shutdown), and then add shutdown -s -t 00 to the end of it to initiate a new shutdown sequence when it's done. You may have to make a couple scripts or something to deal with reboot vs. shutdown vs. hibernation, etc. Are you on an Active Directory domain by any chance?
    – Ƭᴇcʜιᴇ007
    Dec 22 '14 at 19:47












  • It doesn't work. The system closes anyway. It doesn't abort the shutdown. The help says "/A can only be used during the time-out period"
    – user3133076
    Dec 22 '14 at 20:44












  • What edition of Windows is this? Pro, something else?
    – Twisty Impersonator
    Dec 22 '14 at 20:48










  • Windows 7 Home Premium (no gpedit.msc unfortunately)
    – user3133076
    Dec 22 '14 at 21:27










  • Could you have a shortcut to run this item , then use a shutdown command after, instead of fighting a closing down system to run a program then? Just have an assortment of shutdown batches? I use that method from toolbars (like docks)
    – Psycogeek
    Dec 22 '14 at 21:34
















2














When I want to run a program (.exe .bat) before Windows 7 Home Premium Logoff Restart I use the Task Scheduler and I set a custom event: Log: System, Source: Winlogon, Event ID: 7002 4634 4647 .....



The problem is that the program starts but the system closes before the program finishes, while it's running.



What can I do? (My O.S doesn't have gpedit.msc unfortunately)










share|improve this question
























  • Perhaps give this a try (not sure if it'll work): Add shutdown /a to the start of the script (to abort the current shutdown), and then add shutdown -s -t 00 to the end of it to initiate a new shutdown sequence when it's done. You may have to make a couple scripts or something to deal with reboot vs. shutdown vs. hibernation, etc. Are you on an Active Directory domain by any chance?
    – Ƭᴇcʜιᴇ007
    Dec 22 '14 at 19:47












  • It doesn't work. The system closes anyway. It doesn't abort the shutdown. The help says "/A can only be used during the time-out period"
    – user3133076
    Dec 22 '14 at 20:44












  • What edition of Windows is this? Pro, something else?
    – Twisty Impersonator
    Dec 22 '14 at 20:48










  • Windows 7 Home Premium (no gpedit.msc unfortunately)
    – user3133076
    Dec 22 '14 at 21:27










  • Could you have a shortcut to run this item , then use a shutdown command after, instead of fighting a closing down system to run a program then? Just have an assortment of shutdown batches? I use that method from toolbars (like docks)
    – Psycogeek
    Dec 22 '14 at 21:34














2












2








2


1





When I want to run a program (.exe .bat) before Windows 7 Home Premium Logoff Restart I use the Task Scheduler and I set a custom event: Log: System, Source: Winlogon, Event ID: 7002 4634 4647 .....



The problem is that the program starts but the system closes before the program finishes, while it's running.



What can I do? (My O.S doesn't have gpedit.msc unfortunately)










share|improve this question















When I want to run a program (.exe .bat) before Windows 7 Home Premium Logoff Restart I use the Task Scheduler and I set a custom event: Log: System, Source: Winlogon, Event ID: 7002 4634 4647 .....



The problem is that the program starts but the system closes before the program finishes, while it's running.



What can I do? (My O.S doesn't have gpedit.msc unfortunately)







windows-7 windows-task-scheduler logoff






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 26 at 1:16









fixer1234

17.7k144581




17.7k144581










asked Dec 22 '14 at 19:43









user3133076

1001413




1001413












  • Perhaps give this a try (not sure if it'll work): Add shutdown /a to the start of the script (to abort the current shutdown), and then add shutdown -s -t 00 to the end of it to initiate a new shutdown sequence when it's done. You may have to make a couple scripts or something to deal with reboot vs. shutdown vs. hibernation, etc. Are you on an Active Directory domain by any chance?
    – Ƭᴇcʜιᴇ007
    Dec 22 '14 at 19:47












  • It doesn't work. The system closes anyway. It doesn't abort the shutdown. The help says "/A can only be used during the time-out period"
    – user3133076
    Dec 22 '14 at 20:44












  • What edition of Windows is this? Pro, something else?
    – Twisty Impersonator
    Dec 22 '14 at 20:48










  • Windows 7 Home Premium (no gpedit.msc unfortunately)
    – user3133076
    Dec 22 '14 at 21:27










  • Could you have a shortcut to run this item , then use a shutdown command after, instead of fighting a closing down system to run a program then? Just have an assortment of shutdown batches? I use that method from toolbars (like docks)
    – Psycogeek
    Dec 22 '14 at 21:34


















  • Perhaps give this a try (not sure if it'll work): Add shutdown /a to the start of the script (to abort the current shutdown), and then add shutdown -s -t 00 to the end of it to initiate a new shutdown sequence when it's done. You may have to make a couple scripts or something to deal with reboot vs. shutdown vs. hibernation, etc. Are you on an Active Directory domain by any chance?
    – Ƭᴇcʜιᴇ007
    Dec 22 '14 at 19:47












  • It doesn't work. The system closes anyway. It doesn't abort the shutdown. The help says "/A can only be used during the time-out period"
    – user3133076
    Dec 22 '14 at 20:44












  • What edition of Windows is this? Pro, something else?
    – Twisty Impersonator
    Dec 22 '14 at 20:48










  • Windows 7 Home Premium (no gpedit.msc unfortunately)
    – user3133076
    Dec 22 '14 at 21:27










  • Could you have a shortcut to run this item , then use a shutdown command after, instead of fighting a closing down system to run a program then? Just have an assortment of shutdown batches? I use that method from toolbars (like docks)
    – Psycogeek
    Dec 22 '14 at 21:34
















Perhaps give this a try (not sure if it'll work): Add shutdown /a to the start of the script (to abort the current shutdown), and then add shutdown -s -t 00 to the end of it to initiate a new shutdown sequence when it's done. You may have to make a couple scripts or something to deal with reboot vs. shutdown vs. hibernation, etc. Are you on an Active Directory domain by any chance?
– Ƭᴇcʜιᴇ007
Dec 22 '14 at 19:47






Perhaps give this a try (not sure if it'll work): Add shutdown /a to the start of the script (to abort the current shutdown), and then add shutdown -s -t 00 to the end of it to initiate a new shutdown sequence when it's done. You may have to make a couple scripts or something to deal with reboot vs. shutdown vs. hibernation, etc. Are you on an Active Directory domain by any chance?
– Ƭᴇcʜιᴇ007
Dec 22 '14 at 19:47














It doesn't work. The system closes anyway. It doesn't abort the shutdown. The help says "/A can only be used during the time-out period"
– user3133076
Dec 22 '14 at 20:44






It doesn't work. The system closes anyway. It doesn't abort the shutdown. The help says "/A can only be used during the time-out period"
– user3133076
Dec 22 '14 at 20:44














What edition of Windows is this? Pro, something else?
– Twisty Impersonator
Dec 22 '14 at 20:48




What edition of Windows is this? Pro, something else?
– Twisty Impersonator
Dec 22 '14 at 20:48












Windows 7 Home Premium (no gpedit.msc unfortunately)
– user3133076
Dec 22 '14 at 21:27




Windows 7 Home Premium (no gpedit.msc unfortunately)
– user3133076
Dec 22 '14 at 21:27












Could you have a shortcut to run this item , then use a shutdown command after, instead of fighting a closing down system to run a program then? Just have an assortment of shutdown batches? I use that method from toolbars (like docks)
– Psycogeek
Dec 22 '14 at 21:34




Could you have a shortcut to run this item , then use a shutdown command after, instead of fighting a closing down system to run a program then? Just have an assortment of shutdown batches? I use that method from toolbars (like docks)
– Psycogeek
Dec 22 '14 at 21:34










2 Answers
2






active

oldest

votes


















0














What about... A Scheduled Task with the trigger set to "On disconnect from user session", and the "Connection from Local Computer" option set? (A shutdown/restart does logoff/disconnect the user session before powering down, so???)






share|improve this answer

















  • 2




    True, the program starts but I can't make it ends before the system closes. In this way it launches the program and, after few seconds, the O.S. shutdown or restarts.
    – user3133076
    Dec 22 '14 at 21:36










  • I wonder if disabling the switch "If the running task does not end when requested, force it to stop" makes a difference? Or changing the priority of the script to Realtime? Without gpedit is a challenge.
    – Scott
    Dec 22 '14 at 22:52










  • It makes the program "survives" about 4 seconds more, but the problem is the same... Is it sure gpedit resolves this issue?
    – user3133076
    Dec 23 '14 at 9:14










  • Here's the Technet on it... technet.microsoft.com/en-us/library/cc770300.aspx OR, how about create three different scripts on the desktop? Logoff, Shutdown, and Restart. Then call the command at the end of the script, OR write the script to choose your shutdown option? Of course, you'd have to use the shortcuts rather than the Start button power options, but it may suffice.
    – Scott
    Dec 23 '14 at 13:29










  • The Technet solution refers to gpedit.msc and my O.S. doesn't have it. Moreover, I have to restart and shutdown the PC normally.
    – user3133076
    Dec 23 '14 at 15:04



















0














Most probably you will need a tool for doing this. Here you can find 4 that could accomplish what you need with some tunning:



4 Tools to Prevent, Cancel and Abort a Windows System Shutdown



From these I think Shut It! is the best option available. You can configure it to prevent any shutdown while your application is not running and allow them when you app is on. That would do the trick.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f855743%2frun-a-program-before-logoff-and-wait-for-finish%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    What about... A Scheduled Task with the trigger set to "On disconnect from user session", and the "Connection from Local Computer" option set? (A shutdown/restart does logoff/disconnect the user session before powering down, so???)






    share|improve this answer

















    • 2




      True, the program starts but I can't make it ends before the system closes. In this way it launches the program and, after few seconds, the O.S. shutdown or restarts.
      – user3133076
      Dec 22 '14 at 21:36










    • I wonder if disabling the switch "If the running task does not end when requested, force it to stop" makes a difference? Or changing the priority of the script to Realtime? Without gpedit is a challenge.
      – Scott
      Dec 22 '14 at 22:52










    • It makes the program "survives" about 4 seconds more, but the problem is the same... Is it sure gpedit resolves this issue?
      – user3133076
      Dec 23 '14 at 9:14










    • Here's the Technet on it... technet.microsoft.com/en-us/library/cc770300.aspx OR, how about create three different scripts on the desktop? Logoff, Shutdown, and Restart. Then call the command at the end of the script, OR write the script to choose your shutdown option? Of course, you'd have to use the shortcuts rather than the Start button power options, but it may suffice.
      – Scott
      Dec 23 '14 at 13:29










    • The Technet solution refers to gpedit.msc and my O.S. doesn't have it. Moreover, I have to restart and shutdown the PC normally.
      – user3133076
      Dec 23 '14 at 15:04
















    0














    What about... A Scheduled Task with the trigger set to "On disconnect from user session", and the "Connection from Local Computer" option set? (A shutdown/restart does logoff/disconnect the user session before powering down, so???)






    share|improve this answer

















    • 2




      True, the program starts but I can't make it ends before the system closes. In this way it launches the program and, after few seconds, the O.S. shutdown or restarts.
      – user3133076
      Dec 22 '14 at 21:36










    • I wonder if disabling the switch "If the running task does not end when requested, force it to stop" makes a difference? Or changing the priority of the script to Realtime? Without gpedit is a challenge.
      – Scott
      Dec 22 '14 at 22:52










    • It makes the program "survives" about 4 seconds more, but the problem is the same... Is it sure gpedit resolves this issue?
      – user3133076
      Dec 23 '14 at 9:14










    • Here's the Technet on it... technet.microsoft.com/en-us/library/cc770300.aspx OR, how about create three different scripts on the desktop? Logoff, Shutdown, and Restart. Then call the command at the end of the script, OR write the script to choose your shutdown option? Of course, you'd have to use the shortcuts rather than the Start button power options, but it may suffice.
      – Scott
      Dec 23 '14 at 13:29










    • The Technet solution refers to gpedit.msc and my O.S. doesn't have it. Moreover, I have to restart and shutdown the PC normally.
      – user3133076
      Dec 23 '14 at 15:04














    0












    0








    0






    What about... A Scheduled Task with the trigger set to "On disconnect from user session", and the "Connection from Local Computer" option set? (A shutdown/restart does logoff/disconnect the user session before powering down, so???)






    share|improve this answer












    What about... A Scheduled Task with the trigger set to "On disconnect from user session", and the "Connection from Local Computer" option set? (A shutdown/restart does logoff/disconnect the user session before powering down, so???)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 22 '14 at 21:29









    Scott

    11




    11








    • 2




      True, the program starts but I can't make it ends before the system closes. In this way it launches the program and, after few seconds, the O.S. shutdown or restarts.
      – user3133076
      Dec 22 '14 at 21:36










    • I wonder if disabling the switch "If the running task does not end when requested, force it to stop" makes a difference? Or changing the priority of the script to Realtime? Without gpedit is a challenge.
      – Scott
      Dec 22 '14 at 22:52










    • It makes the program "survives" about 4 seconds more, but the problem is the same... Is it sure gpedit resolves this issue?
      – user3133076
      Dec 23 '14 at 9:14










    • Here's the Technet on it... technet.microsoft.com/en-us/library/cc770300.aspx OR, how about create three different scripts on the desktop? Logoff, Shutdown, and Restart. Then call the command at the end of the script, OR write the script to choose your shutdown option? Of course, you'd have to use the shortcuts rather than the Start button power options, but it may suffice.
      – Scott
      Dec 23 '14 at 13:29










    • The Technet solution refers to gpedit.msc and my O.S. doesn't have it. Moreover, I have to restart and shutdown the PC normally.
      – user3133076
      Dec 23 '14 at 15:04














    • 2




      True, the program starts but I can't make it ends before the system closes. In this way it launches the program and, after few seconds, the O.S. shutdown or restarts.
      – user3133076
      Dec 22 '14 at 21:36










    • I wonder if disabling the switch "If the running task does not end when requested, force it to stop" makes a difference? Or changing the priority of the script to Realtime? Without gpedit is a challenge.
      – Scott
      Dec 22 '14 at 22:52










    • It makes the program "survives" about 4 seconds more, but the problem is the same... Is it sure gpedit resolves this issue?
      – user3133076
      Dec 23 '14 at 9:14










    • Here's the Technet on it... technet.microsoft.com/en-us/library/cc770300.aspx OR, how about create three different scripts on the desktop? Logoff, Shutdown, and Restart. Then call the command at the end of the script, OR write the script to choose your shutdown option? Of course, you'd have to use the shortcuts rather than the Start button power options, but it may suffice.
      – Scott
      Dec 23 '14 at 13:29










    • The Technet solution refers to gpedit.msc and my O.S. doesn't have it. Moreover, I have to restart and shutdown the PC normally.
      – user3133076
      Dec 23 '14 at 15:04








    2




    2




    True, the program starts but I can't make it ends before the system closes. In this way it launches the program and, after few seconds, the O.S. shutdown or restarts.
    – user3133076
    Dec 22 '14 at 21:36




    True, the program starts but I can't make it ends before the system closes. In this way it launches the program and, after few seconds, the O.S. shutdown or restarts.
    – user3133076
    Dec 22 '14 at 21:36












    I wonder if disabling the switch "If the running task does not end when requested, force it to stop" makes a difference? Or changing the priority of the script to Realtime? Without gpedit is a challenge.
    – Scott
    Dec 22 '14 at 22:52




    I wonder if disabling the switch "If the running task does not end when requested, force it to stop" makes a difference? Or changing the priority of the script to Realtime? Without gpedit is a challenge.
    – Scott
    Dec 22 '14 at 22:52












    It makes the program "survives" about 4 seconds more, but the problem is the same... Is it sure gpedit resolves this issue?
    – user3133076
    Dec 23 '14 at 9:14




    It makes the program "survives" about 4 seconds more, but the problem is the same... Is it sure gpedit resolves this issue?
    – user3133076
    Dec 23 '14 at 9:14












    Here's the Technet on it... technet.microsoft.com/en-us/library/cc770300.aspx OR, how about create three different scripts on the desktop? Logoff, Shutdown, and Restart. Then call the command at the end of the script, OR write the script to choose your shutdown option? Of course, you'd have to use the shortcuts rather than the Start button power options, but it may suffice.
    – Scott
    Dec 23 '14 at 13:29




    Here's the Technet on it... technet.microsoft.com/en-us/library/cc770300.aspx OR, how about create three different scripts on the desktop? Logoff, Shutdown, and Restart. Then call the command at the end of the script, OR write the script to choose your shutdown option? Of course, you'd have to use the shortcuts rather than the Start button power options, but it may suffice.
    – Scott
    Dec 23 '14 at 13:29












    The Technet solution refers to gpedit.msc and my O.S. doesn't have it. Moreover, I have to restart and shutdown the PC normally.
    – user3133076
    Dec 23 '14 at 15:04




    The Technet solution refers to gpedit.msc and my O.S. doesn't have it. Moreover, I have to restart and shutdown the PC normally.
    – user3133076
    Dec 23 '14 at 15:04













    0














    Most probably you will need a tool for doing this. Here you can find 4 that could accomplish what you need with some tunning:



    4 Tools to Prevent, Cancel and Abort a Windows System Shutdown



    From these I think Shut It! is the best option available. You can configure it to prevent any shutdown while your application is not running and allow them when you app is on. That would do the trick.






    share|improve this answer


























      0














      Most probably you will need a tool for doing this. Here you can find 4 that could accomplish what you need with some tunning:



      4 Tools to Prevent, Cancel and Abort a Windows System Shutdown



      From these I think Shut It! is the best option available. You can configure it to prevent any shutdown while your application is not running and allow them when you app is on. That would do the trick.






      share|improve this answer
























        0












        0








        0






        Most probably you will need a tool for doing this. Here you can find 4 that could accomplish what you need with some tunning:



        4 Tools to Prevent, Cancel and Abort a Windows System Shutdown



        From these I think Shut It! is the best option available. You can configure it to prevent any shutdown while your application is not running and allow them when you app is on. That would do the trick.






        share|improve this answer












        Most probably you will need a tool for doing this. Here you can find 4 that could accomplish what you need with some tunning:



        4 Tools to Prevent, Cancel and Abort a Windows System Shutdown



        From these I think Shut It! is the best option available. You can configure it to prevent any shutdown while your application is not running and allow them when you app is on. That would do the trick.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 16 '17 at 7:30









        Ignacio Soler Garcia

        1,03521222




        1,03521222






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f855743%2frun-a-program-before-logoff-and-wait-for-finish%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Terni

            A new problem with tex4ht and tikz

            Sun Ra