Occasionally I'll be running a script on my local machine that may take a few hours to complete. Sometimes i'll need to leave my desk and of course have to lock my machine.
Normally I always configure power settings not to put my PC to sleep for 2 hours, however this option doesn't apply if your PC is locked. There is a hidden power settings called 'System unattended sleep timeout' that is not visible by default.
To make this setting visible you need to edit a registry entry:
Open the Registry Editor (windows key + r, then type regedit and press enter), then go to:
Computer\\HKEY\_LOCAL\_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Power\\PowerSettings\\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0
You can copy and paste this into the address bar in order to avoid traversing the tree.
Change the Attributes DWORD data to 2, this will add an additional option in Power Settings.
Close the Registry Editor and right click on the start menu and press Power Options > Under Related Settings press Additional Power Settings.
Select your current plan and press Change plan settings > Change advanced power settings and expand Sleep.
Power Options > Advanced settings > Sleep
You should now see the hidden System unattended sleep timeout option. The default period is 2 minutes. You can either specify a new value or set it to zero minutes. This will ensure that your PC does not go to sleep at all when locked.
Once you've set your new timeout value, press Apply to save your changes.