1

Can a Windows scheduled task update itself and how would I do it? I'm using Windows Server 2008. I've seen some Powershell scripts that create tasks from xml; would this be the right approach?

0

You mean update the command that it runs? I suppose so. To summarize:

You schedule a script (I like powershell) that does what you really need done but also checks for newer versions of itself at some central location, and if it's newer then it copies that down to where the scheduled task looks to run the script. OR, it could reimport the scheduled task xml from another location, either way you want to script it.

0

Are you trying to change the Task itself, for example, changing the trigger? If so, Take a look into

SCHTASKS /CHANGE /?

If your task executes some kind of script, then you can include a call to that command on it. However, this would need the run account password (/RP) to be supplied interactively IF your are not using the system, local service or network service account. A DANGEROUS technique you can use is calling this and redirecting the input to a file storing the password, like this:

SCHTASKS /CHANGE /TN YOR_TASK_NAME /RU RUN_USER < FILE_WITH_CLEARTEXT_PASSWORD

So, if your task can run fine with the network service or local service account then go ahead use them. Some people might be wary of using the SYSTEM account, but then again, storing the password in a clear text file seems like a worse option.

  • It seems to me that the other answer is probably much closer to what the asker wanted to know. The idea was most likely to run a self-updating script, not how to change a scheduled task. – Julie Pelletier Aug 19 '16 at 0:37
  • Maybe so, however since it isn't clear and I do see some value on the idea of modifying the task itself (who knows, changing triggers, etc etc) that's why I asked. It's still up to the OP to let us know what the really needed :) – Kemuel Sanchez Aug 20 '16 at 14:55

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.