Using Windows Task Scheduler to facilitate software updates

Windows Task Scheduler (set through the OS) can automatically awaken sleeping computers so that software updates can be applied. Relatively easy to deploy and manage, scheduled tasks are a middle ground between leaving client computers powered 24/7 (so as to be available immediately for software updates), and allowing end users to turn off machines, which then receive software updates upon login. Fusion Trade, Inc. (PDF, 508.34 KB)  saved $70 per PC using EZ GPO and Windows Task Scheduler to accommodate nighttime updates.

Scheduled tasks use the real time clock (RTC) and power management events (PMEs) to wake the machine out of system standby or hibernate. On the settings tab of a scheduled task, an option labeled "Wake the machine to run this task" will set a PME inside the RTC for the time when the task is scheduled to run.

While scheduling a task to wake a single computer is fairly simple, setting a task on multiple machines to wake them requires 3rd party software or custom scripts. Below is a custom script solution that does not require any 3rd party software.

Custom Script Solution

While many properties of a task can be set directly through a script using schtasks.exe the property for "Wake up the machine to run this task" cannot be set this way locally or remotely. In order to create a task that has this property enabled you can copy a preconfigured task that was created using the Windows task scheduler and then reset any necessary properties on the target computer(s) using schtasks.exe. The property for "Wake up the machine to run this task" will be copied over with the task file.

To accomplish this, create a task on one computer that performs any action and configure it to "Wake up the machine to run this task". If there is no desired action to run but you simply want the computer to wake up, you can have it run a blank batch file such as "wakeup.cmd".

When the task has been created a new file will show up in c:\%windir%\Tasks with a .job extension. Copy this file to a network share that is accessible by the account that you will utilize to distribute the task.

To schedule this task, either copy the task to the remote computers or have the computers copy the task through the logon script. Then reset the credentials to run under the desired account.

Copying the File

On a computer from logon script:

copy \\machine\share\wake.job c:\windows\tasks\wakeup.job

To a remote computer:

copy \\machine\share\wake.job \\destinationmachine\c$\windows\tasks\wakeup.job

Changing the Credentials

On a computer from logon script:

schtasks /change /RU domain\UserName /RP PasswordHere /TN wakeup

or to run under the local SYSTEM account:

schtasks /change /RU "SYSTEM" /TN wakeup

To a remote computer:

schtasks /change /S destinationcomputername /RU domain/username /RP PasswordHere /TN wakeup

or to run under the local SYSTEM account:

schtasks /change /S destinationcomputername /RU "SYSTEM" /TN wakeup