I have a scheduled task that wakes the computer at 12am and runs a backup task (SyncToy, run from a batch file). In order to stop the computer going back to sleep from no user activity after 120 seconds, I call the batch file from stayawake.exe (PDF link), which sets SetThreadExecutionState while the backup is running (it appears Microsoft's SyncToy doesn't set this parameter in order to prevent sleep, which is a shame).

Once the task finished, the unattended idle timer slept the computer again 120 seconds after the task finished.

All worked perfectly.

The old laptop was stolen, now I have a new laptop (still W7 Pro). On the new machine I have set a user password on my account (and also enabled a guest account). In order to get my task working correctly, I've found I need to configure the task to 'Run whether user is logged in or not'. I've done this, and the task is again working as expected every night.

The only hitch is that now the computer doesn't sleep 120 seconds after completing the task. It waits for the full 60 minutes that I've configured in Power Settings for a standard 'sleep after inactivity'.

As a workaround, I've modified the batch file to sleep the computer as it's final command, but this is a little messy, as the task doesn't exit cleanly (as the sleep command is sent before the batch file exits, and while StayAwake.exe is running).

Does anyone have any idea why the unattended idle timer either a) doesn't work, or b) thinks there is user activity, when I have the task set to run whether I am logged in or not?

All that's really changed here is that now I have two user accounts, with a password on mine, and I've set the task to run whether I am logged in or not.