Windows 10 Lock screen black after 1 minute

Does your Windows 10 machine power off the screen after 1 minute on the lock screen, leaving you with a black screen after just 1 minute?

Mine did, and it was really irrationally irritating!

There are unfortunately a lot of very similar issues surrounding this and other issues to do with power saving, lock screens and the screen saver which made searching for the right answer very tricky. Lots of advice is given without explanation unfortunately and this makes comparing situations hard.

The fix that worked for me.

The magic setting that worked for me was “Console lock display off timeout” which seems to be carried over from Windows 8/8.1 but oddly remains hidden from view in the advanced power settings in Windows 10.

There are numerous forum posts about setting the registry entry to enable it. However, on my Windows 10 install there appears to be more than one key detailing the change!

There are two registry locations that enable the mystical “Console lock display off timeout”

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0

Which did not work for me, and

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\7516b95f-f776-4464-8c53-06167f40cc99\8EC4B3A5-6868-48c2-BE75-4F3044BE88A7

Which did!

Set the data of the value “Attributes” to 2

This will enable the Console lock display off timeout in the advanced power options.
Once the registry is updated go to Control Panel > Hardware and Sound > Power Options > Edit Plan Settings and then change advanced power settings. In Advanced settings expand Display > the Console lock display off time-out to set the values you want when on battery or plugged in.

The second registry location is referenced by: http://www.eightforums.com/tutorials/8267-power-options-add-console-lock-display-off-timeout.html

Your mileage may vary given how much fun I had. It was compounded by the fact there are a few other places that you may well think should control this setting. I have detailed the online responses that didn’t work.

Other suggested fixes that don’t work

  • This issue is not the same problem as people’s machines actually locking after 1 minute of inactivity. That is a separate issue that seems to be related to preview editions of Windows.
  • Editing the Group Policy
    gpedit.msc > Local group Policy Editor\Local Computer Policy\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options\Interactive Logon: Machine inactivity Limit = 1200 seconds (20 minutes)
    *This is an auto lock policy from what I can see, not too much of an issue if you set it. Default is 0 for never.
  • gpedit.msc > User Configuration > Administrate templates > Control Panel > Personalization
    • Enable screen saver
    • Screen saver timeout
    *Neither of these option had any effect and only confirmed the settings available to users in the usual places.
  • Altering the screen saver from “None” to another screen saver and back again
    *No effect, screen saver never kicks in before 1 minute
  • Right click on your desktop-> Personalise-> Screen Saver and setting time-out to more than 1
    *This should work, and is a logical starting point so but it didn’t
  • Altering the power profile to high performance
    *No noticeable change
  • Updating display drivers
    *Last chance pretty much, also why are you not up to date already?
  • Sacrificing USB memory sticks to the Gods of Windows
    *Thankfully not required this time!
Posted in Microsoft, Windows | Leave a comment

Log shipping across domains with FTP

If you have decided to use SQL Server Log Shipping as a Disaster Recovery (DR) solution, but for whatever reason your offsite data centre or external host isn’t on the same domain as you is Log Shipping still viable?

Yes, but you are going to have to go outside of the usual interface and work those cross company / cross domain issues yourself.

Basic Log Shipping Process

  1. Take Log backups on a schedule every N minutes
  2. Transfer Log backups to N* machines you wish to host a warm DR copy of the database
  3. Restore the Log backup (in either “no recover” or “standby”)
  4. Repeat 1-3
  5. If DR event occurs, restore last Log “With Recovery” and inform users of new DB location

Points 2 and 3, the transfer and restore process, is what you are interested in once outside of the standard process.

Backup

Use the Transaction Log Shipping setup option for your desired master database, but stop short at configuring the secondary server instances.  This will create the master Log backup jobs and schedule them as required.

FTP Transfer

I’ve used FTP as the method to transfer files offsite from the local domain to a hosted DR server in an external data centre. WinSCP is good because it offers a few transmission choices including file synchronisation, is scriptable and free.

Using a scheduled task run WinSCP and load a script.

“C:\Program Files (x86)\WinSCP\WinSCP.exe” /console /script=C:\<yourFilePath>\<BDScript.txt>

Here is the script to sync the directories. You will need to create a connection profile first in WinSCP using the GUI to reference in the script so you don’t need to worry about username / passwords being available in a text file.

# Abort automatically from script on errors
option batch abort
# Disable overwrite confirmations for previous files
option confirm off
#Setup site connection in WinSCP first, ref here
open vm_ls@172.22.21.21
#change local dir
lcd "E:\SQL\LS_Path"
#Change remote path
cd /
#file transfer in binary mode
option transfer binary
#Sync with the remote server, check by size, preserve file time and allow delete
synchronize -delete remote -criteria=size -preservetime -resumesupport=on
#disconnect
close
#Exit WinSCP
exit

SQL Restore

On the secondary server(s) (yes, you can send files to as many servers as required and have licenses for) you need to create the SQL Agent restore job as outside of the usual process SQL Server won’t create the jobs for you on the secondary’s.  You will also need to perform the first time initialisation of the database and leave it in a restoring state to accept further Log backups.

SQL Agent job script

USE [master]
DECLARE
 @LSCopy_Job uniqueidentifier,
 @LSRestore_Job uniqueidentifier,
 @LSSecondary_Id uniqueidentifier

exec sp_add_log_shipping_secondary_primary
 @primary_server = '<machine_name>',
 @primary_database = '<db_name>',
 @backup_source_directory = 'C:\<path>\<here>',
 @backup_destination_directory = 'C:\<path>\<here>',
 @copy_job_name = 'JobNameCopy',
 @restore_job_name = 'JobNameRestore',
 @file_retention_period = 4320, 
 @overwrite = 1,
 @copy_job_id = @LSCopy_Job OUTPUT ,
 @restore_job_id = @LSRestore_Job OUTPUT ,
 @secondary_id = @LSSecondary_Id OUTPUT

exec sp_add_log_shipping_secondary_database
 @secondary_database = '<db_name>',
 @primary_server = '<machine_name>',
 @primary_database = '<db_name>',
 @restore_delay = 0,
 @restore_all = 1,
 @restore_mode = 1,
 @disconnect_users = 1,
 @restore_threshold = 120,
 @threshold_alert_enabled = 1

This script will create two jobs, ‘JobNameCopy’ and ‘JobNameRestore’.  Thanks to the FTP process we don’t need to pull the log backups from the primary server source so the ‘JobNameCopy’ can be deleted or disabled. More info from MSDN here and here.

Now you can configure the timing of the restore job to run at suitable intervals to tie up with your copy process.  Remember that you need to allow time for the FTP copy process to complete before the restore job runs as SQL requires an exclusive lock on the Log backup and part transferred files cannot be included in any running restore process.

Initialise database

Take a full backup of the source database, ship it over (perhaps using your new FTP link?) and restore it, setting the restore option, recovery state to either “Restore with NoRecovery” or “Restore with Standby”

Conclusion

Hopefully you will have a smooth DR process with Log Shipping, even when implemented across the usual company domain boundaries using FTP.  Log Shipping is a highly robust process and works well even over high latency satellite connections with FTP.

Posted in Backups, Microsoft, Networking, SQL Server | Leave a comment