Creating an MSI Package for a Screensaver

Installing a Screensaver Programatically

A screensaver can come in the SCR format. It might need to be packaged up in to an MSI for distribution via GPO or another software distribution tool.

There are three main things you need to do to install a screensaver via an MSI package.

1 – Copy the SCR file down to the system folder. Make sure to use the [SystemFolder] standard MSI directory property to specify the target installation directory rather than hard code C:\Windows\System32. This will mean that the package will still work even if the system folder is not in the expected directory for instance if the machine has been upgraded from Windows 2000 to XP the system folder would be C:\Winnt\System32

2 – Create the registry key to make your newly installed file the selected screensaver. The registry key you need to update is HKCU\Control Panel\Desktop\SCRNSAVE.EXE. You should change the value to be the path to your screensaver.

In your MSI package it is a good idea to use the formatted data type here. That means for the registry value in the MSI enter a value in the format [#scrn.scr] where scrn.scr is the name of a file as it appears in the File table of the MSI. Usually when you see square brackets in an value in an MSI package it means that this value should be expanded at install time to the value of a property in the Property table. However if there is the # prefix it means the value will be expanded to the full file path of the corresponding entry in the File table. This makes the package more flexible and is always better than hard coding a path. If the installation directory is changed the packaged will still work because the formatted data type will pick up the new location.

3 – Because the registry key is written to a user part of the registry and there is no advertised entry point, such as an advertised shortcut, to kick of the required per-user repair to ensure the registry key is written for each new user that logs on then we will have to force the package to run a repair each time a new user logs on.

To force per-user repair at each new log on an Active Setup registry key can be used. This involves creating a new key in the package at HKLM\Software\Microsoft\Active Setup\Installed Components followed by a guid. Then enter a string registry value named StubPath and give it a value of msiexec /fpu {productcode} /qn where productcode should be replaced with the ProductCode property from the package. The f switch stands for repair (or fix), the pu tells it to repair files and the user part of the registry. The qn makes it a silent repair.

Once the package is installed a reboot is required for the new screen saver settings to take effect.

By default the timeout for the screensaver is 600 seconds but for testing you might want to lower this by changing the HKCU\Control Panel\Desktop\ScreenSaveTimeOut value to be something lower.

One thing I have noticed with this approach, even though it works, is that when I right click on the desktop and choose properties and then the screensaver tab the new screensaver is not selected as the visible default option in the list.