Ask Your Question

Windows scheduled task trigger on system start

asked 2014-11-12 19:23:56 -0600

anthv123 gravatar image

Looking at the docs it seems as though puppet does not support creating a trigger for a Windows scheduled task on system start ("at system startup").

Currently, I just run a schtasks.exe command to create a scheduled task that triggers on system start, but I would love to use the 'scheduled_task' module if possible.

Are there any workarounds to this problem or will there be support in the future for this feature?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-11-12 19:56:10 -0600

DJB gravatar image

Unfortunately there is no trigger for startup available today. If you find yourself creating many scheduled tasks on starup you can create a defined resource type to fufill this requirement.

define startup_tasks ($title, $ensure, $command) {
  if $ensure == present {
    exec { "create_${title}":
      command      => "schtasks /CREATE /SC ONSTART /TN ${title} /TR ${command}",
      unless       => "schtasks /QUERY /TN ${title}",
      provider     => powershell,

  if $ensure == absent {
    exec { "delete_${title}":
      command      => "schtasks /DELETE /TN ${title}",
      onlyif       => "schtasks /QUERY /TN ${title}",
      provider     => powershell,

now you should be able to create tasks with this new resource in other classes. e.g.

startup_tasks { 'cool_task':
  ensure      => present,
  command     => 'calc.exe',
edit flag offensive delete link more


There will be oddities wrong with this example but this was recommended to me, and worked well for similar situation.

DJB gravatar imageDJB ( 2014-11-12 19:59:20 -0600 )edit

Pretty frustrating the startup trigger isn't available given the fact it's a simple cli flag.

anthv123 gravatar imageanthv123 ( 2014-11-13 12:00:17 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-11-12 19:23:56 -0600

Seen: 1,280 times

Last updated: Nov 12 '14