how to configure “stop the task if it runs longer than” for schtasks.exe












0














I want to set the value for the option "Stop task if runs longer than" in the windows schedule task Trigger tab using Powershell.



Already tried with /DU switch but it is not working.



Below is the screenshot for the same.
Windows Task Schedule Trigger Settings



let me know in case of any further information is required.



@TobyU: I tried your suggestion as well but it is not setting up the required value. Below is the screenshot for your reference.
enter image description here



Thank you in advance.










share|improve this question





























    0














    I want to set the value for the option "Stop task if runs longer than" in the windows schedule task Trigger tab using Powershell.



    Already tried with /DU switch but it is not working.



    Below is the screenshot for the same.
    Windows Task Schedule Trigger Settings



    let me know in case of any further information is required.



    @TobyU: I tried your suggestion as well but it is not setting up the required value. Below is the screenshot for your reference.
    enter image description here



    Thank you in advance.










    share|improve this question



























      0












      0








      0







      I want to set the value for the option "Stop task if runs longer than" in the windows schedule task Trigger tab using Powershell.



      Already tried with /DU switch but it is not working.



      Below is the screenshot for the same.
      Windows Task Schedule Trigger Settings



      let me know in case of any further information is required.



      @TobyU: I tried your suggestion as well but it is not setting up the required value. Below is the screenshot for your reference.
      enter image description here



      Thank you in advance.










      share|improve this question















      I want to set the value for the option "Stop task if runs longer than" in the windows schedule task Trigger tab using Powershell.



      Already tried with /DU switch but it is not working.



      Below is the screenshot for the same.
      Windows Task Schedule Trigger Settings



      let me know in case of any further information is required.



      @TobyU: I tried your suggestion as well but it is not setting up the required value. Below is the screenshot for your reference.
      enter image description here



      Thank you in advance.







      powershell scheduler windowstaskschedule






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 13:34

























      asked Nov 12 at 12:40









      Shaikh Farooque

      2,25011228




      2,25011228
























          1 Answer
          1






          active

          oldest

          votes


















          2














          You can set it for the whole task at once:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Settings.ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Stops after 3 hours in the above example.



          This is how you set it only for a specific trigger:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Triggers[0].ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Where Triggers[0] is the specific trigger you want to adjust since $task.Triggers returns an array with all the available trigger objects for the specific task.






          share|improve this answer























          • ExecutionTimeLImit string format: The amount of time that is allowed to complete the task. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). A value of PT0S will enable the task to run indefinitely. When this parameter is set to Nothing, the execution time limit is infinite.
            – Theo
            Nov 12 at 13:15










          • the string format here is not intuitive. At least not at first. you need to add information about how to make those strings in the desired format. e.g. docs.microsoft.com/en-us/windows/desktop/taskschd/…
            – Matt
            Nov 12 at 13:17












          • The above provided PS script is not setting it up. but no luck, it is not changing the value.
            – Shaikh Farooque
            Nov 12 at 13:32






          • 1




            It's setting it for the whole task, not only for a trigger.
            – TobyU
            Nov 12 at 13:34










          • @TobyU: you are right it is setting up for the whole task, but i want it only for a specific trigger. how to achieve that.
            – Shaikh Farooque
            Nov 13 at 6:51











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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%2fstackoverflow.com%2fquestions%2f53262396%2fhow-to-configure-stop-the-task-if-it-runs-longer-than-for-schtasks-exe%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You can set it for the whole task at once:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Settings.ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Stops after 3 hours in the above example.



          This is how you set it only for a specific trigger:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Triggers[0].ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Where Triggers[0] is the specific trigger you want to adjust since $task.Triggers returns an array with all the available trigger objects for the specific task.






          share|improve this answer























          • ExecutionTimeLImit string format: The amount of time that is allowed to complete the task. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). A value of PT0S will enable the task to run indefinitely. When this parameter is set to Nothing, the execution time limit is infinite.
            – Theo
            Nov 12 at 13:15










          • the string format here is not intuitive. At least not at first. you need to add information about how to make those strings in the desired format. e.g. docs.microsoft.com/en-us/windows/desktop/taskschd/…
            – Matt
            Nov 12 at 13:17












          • The above provided PS script is not setting it up. but no luck, it is not changing the value.
            – Shaikh Farooque
            Nov 12 at 13:32






          • 1




            It's setting it for the whole task, not only for a trigger.
            – TobyU
            Nov 12 at 13:34










          • @TobyU: you are right it is setting up for the whole task, but i want it only for a specific trigger. how to achieve that.
            – Shaikh Farooque
            Nov 13 at 6:51
















          2














          You can set it for the whole task at once:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Settings.ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Stops after 3 hours in the above example.



          This is how you set it only for a specific trigger:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Triggers[0].ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Where Triggers[0] is the specific trigger you want to adjust since $task.Triggers returns an array with all the available trigger objects for the specific task.






          share|improve this answer























          • ExecutionTimeLImit string format: The amount of time that is allowed to complete the task. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). A value of PT0S will enable the task to run indefinitely. When this parameter is set to Nothing, the execution time limit is infinite.
            – Theo
            Nov 12 at 13:15










          • the string format here is not intuitive. At least not at first. you need to add information about how to make those strings in the desired format. e.g. docs.microsoft.com/en-us/windows/desktop/taskschd/…
            – Matt
            Nov 12 at 13:17












          • The above provided PS script is not setting it up. but no luck, it is not changing the value.
            – Shaikh Farooque
            Nov 12 at 13:32






          • 1




            It's setting it for the whole task, not only for a trigger.
            – TobyU
            Nov 12 at 13:34










          • @TobyU: you are right it is setting up for the whole task, but i want it only for a specific trigger. how to achieve that.
            – Shaikh Farooque
            Nov 13 at 6:51














          2












          2








          2






          You can set it for the whole task at once:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Settings.ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Stops after 3 hours in the above example.



          This is how you set it only for a specific trigger:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Triggers[0].ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Where Triggers[0] is the specific trigger you want to adjust since $task.Triggers returns an array with all the available trigger objects for the specific task.






          share|improve this answer














          You can set it for the whole task at once:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Settings.ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Stops after 3 hours in the above example.



          This is how you set it only for a specific trigger:



          $task = Get-ScheduledTask -TaskName "MyTask"
          $task.Triggers[0].ExecutionTimeLimit = "PT3H"
          Set-ScheduledTask $task


          Where Triggers[0] is the specific trigger you want to adjust since $task.Triggers returns an array with all the available trigger objects for the specific task.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 at 7:31

























          answered Nov 12 at 12:48









          TobyU

          2,173621




          2,173621












          • ExecutionTimeLImit string format: The amount of time that is allowed to complete the task. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). A value of PT0S will enable the task to run indefinitely. When this parameter is set to Nothing, the execution time limit is infinite.
            – Theo
            Nov 12 at 13:15










          • the string format here is not intuitive. At least not at first. you need to add information about how to make those strings in the desired format. e.g. docs.microsoft.com/en-us/windows/desktop/taskschd/…
            – Matt
            Nov 12 at 13:17












          • The above provided PS script is not setting it up. but no luck, it is not changing the value.
            – Shaikh Farooque
            Nov 12 at 13:32






          • 1




            It's setting it for the whole task, not only for a trigger.
            – TobyU
            Nov 12 at 13:34










          • @TobyU: you are right it is setting up for the whole task, but i want it only for a specific trigger. how to achieve that.
            – Shaikh Farooque
            Nov 13 at 6:51


















          • ExecutionTimeLImit string format: The amount of time that is allowed to complete the task. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). A value of PT0S will enable the task to run indefinitely. When this parameter is set to Nothing, the execution time limit is infinite.
            – Theo
            Nov 12 at 13:15










          • the string format here is not intuitive. At least not at first. you need to add information about how to make those strings in the desired format. e.g. docs.microsoft.com/en-us/windows/desktop/taskschd/…
            – Matt
            Nov 12 at 13:17












          • The above provided PS script is not setting it up. but no luck, it is not changing the value.
            – Shaikh Farooque
            Nov 12 at 13:32






          • 1




            It's setting it for the whole task, not only for a trigger.
            – TobyU
            Nov 12 at 13:34










          • @TobyU: you are right it is setting up for the whole task, but i want it only for a specific trigger. how to achieve that.
            – Shaikh Farooque
            Nov 13 at 6:51
















          ExecutionTimeLImit string format: The amount of time that is allowed to complete the task. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). A value of PT0S will enable the task to run indefinitely. When this parameter is set to Nothing, the execution time limit is infinite.
          – Theo
          Nov 12 at 13:15




          ExecutionTimeLImit string format: The amount of time that is allowed to complete the task. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). A value of PT0S will enable the task to run indefinitely. When this parameter is set to Nothing, the execution time limit is infinite.
          – Theo
          Nov 12 at 13:15












          the string format here is not intuitive. At least not at first. you need to add information about how to make those strings in the desired format. e.g. docs.microsoft.com/en-us/windows/desktop/taskschd/…
          – Matt
          Nov 12 at 13:17






          the string format here is not intuitive. At least not at first. you need to add information about how to make those strings in the desired format. e.g. docs.microsoft.com/en-us/windows/desktop/taskschd/…
          – Matt
          Nov 12 at 13:17














          The above provided PS script is not setting it up. but no luck, it is not changing the value.
          – Shaikh Farooque
          Nov 12 at 13:32




          The above provided PS script is not setting it up. but no luck, it is not changing the value.
          – Shaikh Farooque
          Nov 12 at 13:32




          1




          1




          It's setting it for the whole task, not only for a trigger.
          – TobyU
          Nov 12 at 13:34




          It's setting it for the whole task, not only for a trigger.
          – TobyU
          Nov 12 at 13:34












          @TobyU: you are right it is setting up for the whole task, but i want it only for a specific trigger. how to achieve that.
          – Shaikh Farooque
          Nov 13 at 6:51




          @TobyU: you are right it is setting up for the whole task, but i want it only for a specific trigger. how to achieve that.
          – Shaikh Farooque
          Nov 13 at 6:51


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53262396%2fhow-to-configure-stop-the-task-if-it-runs-longer-than-for-schtasks-exe%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

          Bressuire

          Vorschmack

          Quarantine