0

I'm having trouble getting schtasks.exe to create a Sheduled task that will:

Start at logon Repeat at minute intervals I've tried the following:

schtasks /Create /SC MINUTE /MO 1 /TR "C:\windows\system32\calc.exe" /TN "Run Doo Dad" /RU "user" /RP "secret" /F

Which creates a task that starts one minute after it's created and will repeat, but does not successfully start again after a reboot. This appears to create a "One Time" trigger, which is of dubious usefulness, but is apparently part of the design.

When I attempt to use "/SC ONLOGON" (while supplying /RU and /RP), I am rewarded with "Error: access is denied." Even if I were to be granted access, The Famous Manual (https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx) says that the ONLOGON event cannot have modifiers, and it is unclear how one actually specifies repeating tasks for ONLOGON with the command line.

I am quite near to losing my mind, here. I'm coming from a unix background, and am wistfully dreaming of the simplicity of cron.

The answers "Just Do it in the GUI" or "Create an XML File" are not acceptable in our situation. I might be amenable to "Do it with pywin32" but the only examples I saw are limited in almost exactly the same way,and I can't find proper documentation anyway.

I don't know enough about powershell to know where to begin, but I'm amenable to learning.

Any suggestions appreciated.

8
  • Why are you creating a duplicate of your already existing question? I can tell because you copied the reputation vote information. What was wrong with your previous attempt that is causing you to ask the same question again?
    – Ramhound
    Apr 9, 2015 at 22:15
  • What Ramhound said. And what is that you're trying to achieve? There might be a better solution than what you're currently desperately trying to get working. What is your intention?
    – megamorf
    Apr 10, 2015 at 0:24
  • Ramhound: I posted this originally on stackoverflow, and had the helpful suggestion that I move it here. I'm very, very sorry that I inadvertently copied some confusing information and hope it did not intrude on your time unduly.
    – lysdexia
    Apr 10, 2015 at 1:13
  • megamorf: I'm attempting to create windows scheduled tasks from the command line. I must deploy machines with customized commands in these tasks. Sometimes as many as 15 per system. Creating many tasks via the gui is very time consuming, so I thought I might create a script that could do it for me.
    – lysdexia
    Apr 10, 2015 at 1:17
  • I have successfully created Scheduled Task xml files which I can import using the gui, but again, I cannot do this via the command line. That is outlined in another question, so as not to muddy the waters.
    – lysdexia
    Apr 10, 2015 at 1:19

1 Answer 1

0

Eventually solved this issue by dispatching with windows scheduler altogether. Instead re-wrote the script to handle it's own looping/locking and used NSSM "The Non-Sucking Service Manager" https://nssm.cc/ to handle the actual start/stop duties.

This is obviously not an answer to the original question, as I had to punt by rewriting the script and installing a third-party program.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .