Eldad Assis
Eldad Assis

Reputation: 11045

Windows task scheduler edit multiple tasks together

Windows 2008 server.

Is it possible to edit multiple tasks at the same time (batch update)?

I have several tasks. I want to edit the command line in the action tab. The tasks are automatically created by a build process and are executed later (single run). The task also removes itself, so there are no leftovers.

Upvotes: 1

Views: 3259

Answers (1)

Eldad Assis
Eldad Assis

Reputation: 11045

Here is what I did to resolve my needs:

  • List all tasks to a csv file: schtasks /query /v /fo csv > c:\temp\tasks.csv
  • Using regex, I edited the csv file to leave only the task name and action
  • Edit the csv file with the updates I want (my case - the action)
  • Batch file with a loop to go over all entries in the file and run schtasks /change /tn "name" /tr "new action" /rp

A sample line in the csv: "my task name","my new action"

The batch file content:

@echo off
for /F "tokens=1,2 delims=," %%a in (C:\temp\tasks.csv) do (
    echo Fixing Task: %%a
    schtasks /change /tn %%a /tr %%b /rp <password>
)

I hope this helps...

Upvotes: 2

Related Questions