Introduction to Windows Services in MSIX
Up until 2020, Windows Services were not supported in MSIX -- which represented a blocker for organizations looking to transition their applications (that used Windows Services) to MSIX technology.
Now that Windows Services are finally available in MSIX, many professionals and companies are willing to prepare for the switch.
In this article, we will be talking about:
- What are Windows Services, and how do they now relate to MSIX;
- Where are the Windows Services stored within the manifest file;
- How to use Advanced Installer to add, manage and update Windows Services in your package.
What are Windows Services?
Formerly known as NT services, Microsoft "Windows Services" are computer programs in the form of executables, which enable developers to create long-running executable applications that can be automatically or manually started, stopped or restarted. These kinds of executables operate in the background.
The central utility provided by Microsoft to administer services (which is built-in all Windows versions) is Windows Services Control Manager. To access it, you just need to use the services.msc command.
When did MSIX start supporting Windows Services?
Microsoft announced their plan in regards to Windows Services in late 2019 at the AppManagEvent conference. And following through, starting with Windows 10, version 2004, Microsoft introduced support for running an MSIX package that included Windows Services.
The below diagram shows the OS resources that are supported for a Win32 application from an MSIX perspective.
MSIX packages that have Windows Services included within them require elevation in order to get installed. This is because Windows Services are deployed natively and run outside the MSIX container.
Finding Windows Services in the MSIX Manifest File
The AppxManifest.xml contains all the information needed by the system to deploy an MSIX package -- so naturally, this is where all the information about Windows Services is stored.
But, where exactly and what information will you find? Let’s assume you have an MSIX package that has Windows Services.
If you decompress the MSIX package and have a look at the AppxManifest.xml file, you will notice that the Service entry is included within the Extensions section of the AppxManifest.xml. It specifies the configuration of the Windows Service that is installed and registered along with the MSIX package.
<Extensions> <desktop6:Extension Category="windows.service" EntryPoint="Windows.FullTrustApplication" Executable="WindowsServiceSample.exe"> <desktop6:Service Name="WindowsService Sample" StartAccount="localSystem" StartupType="auto"/> </desktop6:Extension> </Extensions>
This Service entry comes with the following attributes:
- Name - the name of the service (capped at a maximum of 32,767 characters in length and must include a non-whitespace character at the beginning and end)
- StartAccount - the startup type for the service (it must be set to one of the following values: auto, manual, or disabled)
- StartType - the type of account where you run the service (it must be set to one of the following values: localSystem, localServices or networkService)
- Arguments - the list of arguments to pass to the service (this is optional, but if you need to pass any argument, then it must have a maximum of 32,767 characters in length and include a non-whitespace character at the beginning and the end)
Additionally, because the Windows Service within the MSIX package runs outside the MSIX container, you also need to declare the required Capabilities, as seen here:
The localSystemServices capability is required only for Local System services, whereas packagedServices is required for either Local Service, Network Service or Local System services. You can find more details about restricted capabilities here.
Although all the information about Windows Services is stored in the MSIX manifest file, if you wanted to manually add or update a Windows Service to your application, you will have to go through all the above steps and manually amend the AppxManifest.xml in a text editor.
That means it's going to be a hassle to manage Windows Services manually. I recommend that you choose a tool to make the job for you, rather than manually modifying the Manifest file.
Here's where Advanced Installer comes to the rescue.
How to: Add a Windows Service Using Advanced Installer
If you have a package with Windows Services that you want to modify or if you want to add or configure a Windows Service to a package, you will find Advanced Installer's GUI most helpful.
There are two simple steps to follow:
1. Go to the “Declarations” page, right-click on the app, and then click on “Add Application Declaration – Service”
2. In the “Service Properties” panel, specify the configuration of your Windows Service based on the four attributes we mentioned above: Name, StartAccount, StartType and Arguments.
Watch this video to see a demo of the above steps:
And that's it! Once you add a Windows Service, it gets automatically managed by Advanced Installer, so you don't even have to review and declare the capabilities needed for the App Installer to install it.
The Manifest Editor enables the edit of the MSIX package manifest within Advanced Installer. You can use the Manifest Editor starting with version 17.0.
Now, let’s take the newly created MSIX package and install it on a device (remember that you need minimum Windows 10, version 2004). The App Installer will prompt you with the list of all the capabilities added within the MSIX packages.
Once the MSIX package is installed, you can go to Windows Services Control Manager and check if your Windows Services are loaded in there. If you double-click on the corresponding Windows Service registered by your MSIX package, you will be able to see its details.
As you can see in the screenshot below, the “Path to executable” still points to MSIX Root folder -- although the Windows Service runs outside the MSIX container.
When uninstalled, the MSIX package will also remove the Windows Service that was loaded during the installation.
The incorporation of Windows Services support in MSIX packages is a significant step forward in helping organizations to take the leap into MSIX migration. And, together with the improvements carried out to MSIX runtime and Package Support Framework, it will substantially improve the effectiveness of MSIX migration.
Have you used the Windows Services with your MSIX package yet? Let us know your experience in the comments below.
Subscribe to Our Newsletter
Sign up for free and be the first to receive the latest news, videos, exclusive How-Tos, and guides from Advanced Installer.