How to apply a dynamic background via Active Directory GPP

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

Step 1 – Creating Backgrounds

Designing backgrounds are out of scope for this article but a few guidelines are listed below

 

Using information from https://en.wikipedia.org/wiki/Display_resolution we can conclude that we mainly need to cater for 16:9, 16:10, 4:3 and 5:4 aspect ratios with a maximum width of 7680px.

 

If the required background is mainly horizontal, use this guide to create four different versions of background image

ScreenResolutions.jpgAlternatively, if the image is mainly vertical, start with a 10 924px x 6144px
image and crop to create four different versions of background image

ScreenRatios.png

 

Step 2 – User Environmental Variables

After creating the four different versions of the background, we need a way to control which version of background is pushed to the computers.

 

Create four user environmental variable objects using GPO User Environmental Preferences

 

1.png
2.png
3.png
4.pngHere is the values required to create the four entries

  • 16:9 – PrimaryScreenAspectRatio = 1.778
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1280′ and ScreenHeight=’720′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1600′ and ScreenHeight=’900′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1920′ and ScreenHeight=’1080′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’2560′ and ScreenHeight=’1440′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’3840′ and ScreenHeight=’2160′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’7680′ and ScreenHeight=’4320′
  • 16:10 PrimaryScreenAspectRatio = 1.6
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1280′ and ScreenHeight=’800′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1440′ and ScreenHeight=’900′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1680′ and ScreenHeight=’1050′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1920′ and ScreenHeight=’1200′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’2560′ and ScreenHeight=’1600′
  • 4:3 PrimaryScreenAspectRatio = 1.333
    • Select * from Win32_DesktopMonitor where ScreenWidth=’320′ and ScreenHeight=’200′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’640′ and ScreenHeight=’480′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’800′ and ScreenHeight=’600′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1024′ and ScreenHeight=’768′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1152′ and ScreenHeight=’864′
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1600′ and ScreenHeight=’1200′
  • 5:4 PrimaryScreenAspectRatio = 1.25
    • Select * from Win32_DesktopMonitor where ScreenWidth=’1280′ and ScreenHeight=’1024

A C# application can be deployed as an addition to the GPO User Environmental Variables Preference Items as a GPO User File Preference. This is useful on RDP sessions and Hyper-V consoles where the WMI objects are not populated properly.

 

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SetXRes
{
    class Program
    {
        static void Main(string[] args)
        {

            double primaryScreenAspectRatio;
            Rectangle resolution = Screen.PrimaryScreen.Bounds;
            primaryScreenAspectRatio = Math.Round(((double)resolution.Width / (double)resolution.Height), 3);

            Console.WriteLine(resolution.Width);
            Console.WriteLine(resolution.Height);
            Console.WriteLine(primaryScreenAspectRatio.ToString().Replace(',', '.'));

            Environment.SetEnvironmentVariable("PrimaryScreenAspectRatio", primaryScreenAspectRatio.ToString().Replace(',','.'), EnvironmentVariableTarget.User);
        }
    }
}

 

 

Step 3 – Background File Deployment

Create four file objects using GPO User Files Preferences

 

Based on the User Environmental Variable set in the previous step, an appropriately ratioed background file will be pushed to computers

5.png
6.png
7.png
8.pngHere is the values required to create the four entries

  • 16:9 – Source file(s) \\YOURDOMAIN.com\NETLOGON\Backgrounds\16-9.PNG
    • the environment variable %PrimaryScreenAspectRatio% is 1.778
  • 16:10 Source file(s) \\YOURDOMAIN.com\NETLOGON\Backgrounds\16-10.PNG
    • the environment variable %PrimaryScreenAspectRatio% is 1.6
  • 4:3 16:10 Source file(s) \\YOURDOMAIN.com\NETLOGON\Backgrounds\4-3.PNG
    • the environment variable %PrimaryScreenAspectRatio% is 1.333
  • 5:4 16:10 Source file(s) \\YOURDOMAIN.com\NETLOGON\Backgrounds\5-4.PNG
    • the environment variable %PrimaryScreenAspectRatio% is 1.25

The target file for all of these entries is %AppDataDir%\Branding\Background\Background.png

Step 4 – Applying Background

Now for the easy bit, just configure the background %AppData%\Branding\Background\Background.png.

Because the background is dynamically assigned, it will always have the same path on the computers

 

9.png
10.png

Windows 10 1607 Build 14939 Error “This app can’t open”

On most installations of Windows 10 the 1607 update installs without a problem. It just happens to be that my laptop is not most installations. For one, I am using deduplication which is a server feature not to mention all my developer tools.

After installation, my deduplication stopped working which I fixed with new 14939 packages and none of my store apps worked. I fact my store didn’t even open.

thisappcantopen
Error “This app can’t open”

Managed to fix store by running wsreset.exe after which I could repair all my apps

Error 0x800F0922 or 0x800F0902 when installing SNMP Service

Had an interesting issue. Our installation of SNMP service kept failing.

The same error was shown when using PowerShell, DISM and Server manager.

Long story short, weirdly the installation is only deemed successful if the service can start, if it cannot, the whole installation is rolled back.

In our case a 3rd party app was hogging UDP 161 and SNMP failed to start hence the installation kept rolling back.

The culprit was identified by looking for the process that uses UDP 161 in output of command “NETSTAT -anb”

After killing this process installation work

Unable to create folder on drive mapped to share with ABE enabled

Struggled for a bit with Windows 7 computers that could not create folders on mapped drives via Explorer. Doing the same via command prompt creates the folder successfully.

Turns out that ABE, which was setup correctly, was causing the issue and that themaids on http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2012/Q_28509884.html had the same issue.

Weird enough you give Domain Users read/execute, List folder contents, and read permissions and instantly the Windows 7 clients can create folders again and, best of all, ABE is still working