I know you can create and edit the actions and triggers of a scheduled task via CMD, but when I open the created task in Task Scheduler all of the Conditions are set to their default configurations. I've tried looking them up in the microsoft documentation but all I've been able to find are the switches /options for the actions and triggers portion of the scheduled task.

I'd like to be able to do this via Command line so that I can deploy this scheduled task to all of our Windows 10 workstations with PDQ deploy.

For reference, here is the command I am currently working with

'schtasks /create /tn SeatSaver /tr "taskkill /F /IM Executable.EXE" /sc 
ONIDLE /i 60 /ru domain\username /rp password' 

according to the documentation this command should create a task that kills a certain program after 60 minutes of the Workstation being idle. But when I open up the created task and look at the conditions, the options for conditions are all at their default settings, which to me means that the command won't work as is, because the default setting for idling is to not care if the PC is idle, which I don't want.

Is there anyway to make this work via CMD?

Edit: I've read through Microsoft's Powershell Documentation for this, but I wasn't able to find anything regarding the "OnIdle" trigger, or if it even exists. Does anyone have a list of Triggers for setting up scheduled tasks with Powershell?



  • You can almost certainly do this using Powershell. The tools under cmd are somewhat limited. – Zoredache Jul 30 '18 at 22:28
  • I looked through the Microsoft Docs regarding the Powershell cmdlets for Scheduled tasks. See my edit. – McITGuy Jul 30 '18 at 22:51
  • Why are you specifying the /U switch? That is for connecting to a remote system, which you are not doing. When I ran the command using /RU switch it works as expected. – Greg Askew Jul 31 '18 at 12:47
  • oh yeah, I was working on a small workstation remotely for this. I copy and pasted the command but I guess I took out the /ru and /rp switches instead of the /u and /p switches. Brainfart I guess. I'll edit the post – McITGuy Jul 31 '18 at 14:04

The New-ScheduledTask command has a settings parameter that accepts a settings object, which can be created using New-ScheduledTaskSettingsSet and that has a -RunOnlyIfIdle parameter.

This implies that 'on idle' is not a trigger in itself, but a limiting control on the trigger that stops the task running if the host is not idle.

Perhaps in CMD you also require a periodic schedule to get your ONIDLE, such as by using the /MO and /ST parameters.

  • So basically, I would create a task that runs every hour or so, but then set the condition that it would only run if the PC is idle? I guess that would work. I'll tinker around with it to see if it works. Thanks – McITGuy Jul 31 '18 at 14:17

Alright, I'm an idiot. I just realized you can export Scheduled tasks as xml files then create a new task using the schtasks /create /xml "xmlfile.xml" command. I'm just going to do that and deploy it with PDQ.

Thanks guys.

  • I was going to mention that but it wasn’t really what you were asking for. Ideally you need to select an answer, even if it’s your own. – john Aug 1 '18 at 5:47
  • 1
    Yeah, I have to wait another 6 hours before I can select my own answer. Don't worry, I will. – McITGuy Aug 1 '18 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.