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?
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.
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.