#1 25 Jun 2018 13:24

RG
Member
From: Minnesota
Registered: 18 Feb 2010
Posts: 344

schtasks onidle only triggers once

I am trying to trigger a task whenever the computer goes idle. I need to do this in an install package, so I am using schtasks. I am able to create a task, but it only triggers once. I am expecting it to trigger again the next time the computer enters the idle state. Here is my code:

schtasks /create /tn "My Task Name" /tr "My Task To Run" /sc onidle /i 1 /ru SYSTEM

The task triggers and runs properly one time. What am I missing to get it to run again when the computer goes idle?
Thanks for any ideas.


CMD and InstallShield

Offline

#2 26 Jun 2018 08:21

Pyprohly
Member
Registered: 26 Nov 2014
Posts: 37

Re: schtasks onidle only triggers once

This question isn’t really a command line problem… I can only suggest carefully reviewing and tweaking the options from within the Task Scheduler GUI.

Offline

#3 26 Jun 2018 08:32

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,052

Re: schtasks onidle only triggers once

Pyprohly: We don't need to be that parochial smile

RG:
There's a fair bit of info about how "idle" is determined here, might provide some insight based on your environment/behaviours:
https://docs.microsoft.com/en-gb/window … conditions

Some other avenues to explore:
Do you see the same behaviour running "onidle" tasks against a named user, rather that "SYSTEM"?
On the vein of Pyprohly's comment, what behaviour do you see for tasks created via the GUI?
If GUI versions work, is there any visible difference in config between them when you do this?

schtasks /query /V

Last edited by bluesxman (26 Jun 2018 13:55)


cmd | *sh | Ruby | Chef | Puppet | PowerShell | AutoIT3

Offline

#4 03 Jul 2018 20:49

RG
Member
From: Minnesota
Registered: 18 Feb 2010
Posts: 344

Re: schtasks onidle only triggers once

Thanks bluesxman.
Yes, I have been over the link you posted and this text in it (below) appears to be exactly what I want. However, it does not seem to work. It will trigger once and that is it.

"Cycling Idle Condition
If the computer is cycling in and out of the idle state, you can terminate and restart the task using the following idle conditions. To terminate and restart a task, both properties and elements must be set to True:
To terminate the task when the idle condition ends, set the StopOnIdleEnd property or the StopOnIdleEnd element to True.
To restart the task when the computer cycles into the idle condition again, set the RestartOnIdle property or the RestartOnIdle element to True."

BTW, same results achieved when done from GUI.

Last edited by RG (03 Jul 2018 20:50)


CMD and InstallShield

Offline

Board footer

Powered by FluxBB