how to configure “stop the task if it runs longer than” for schtasks.exe
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.
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.
Thank you in advance.
powershell scheduler windowstaskschedule
add a comment |
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.
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.
Thank you in advance.
powershell scheduler windowstaskschedule
add a comment |
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.
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.
Thank you in advance.
powershell scheduler windowstaskschedule
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.
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.
Thank you in advance.
powershell scheduler windowstaskschedule
powershell scheduler windowstaskschedule
edited Nov 12 at 13:34
asked Nov 12 at 12:40
Shaikh Farooque
2,25011228
2,25011228
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
|
show 2 more comments
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
|
show 2 more comments
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.
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
|
show 2 more comments
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.
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.
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
|
show 2 more comments
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
|
show 2 more comments
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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