Shell extension contextual menu not showing when installing for all users

Romain Braussen 1 Reputation point
2022-12-08T11:32:39.383+00:00

Hi,

I successfully implemented a packaged msix application registering a shell extension handler in its manifest to open any file with my application.
This is working fine per-user, if you just install the application double-clicking the *.msix. You can right-click a file and the menu appears.

However this application will likely be deployed on multiple machines for all user, in a machine scope.
This can be done via the Powershell command
Add-AppxProvisionedPackage -Online -SkipLicense -PackagePath .\MyPackagePackage_1.0.0.0_x64.msix

But if installing like this, the contextual menu is not showing. The application is still installed for all users, I can see it in the "Apps&Features" list, and I can manually launch it, but not the shell extension. I have put some logs in it and it seems to just never be called.

Below is the manifest I am using (with private info removed) :

<?xml version="1.0" encoding="utf-8"?>  
  
<Package  
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"  
  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"  
  xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"  
  xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"  
  xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"  
  xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"  
  xmlns:desktop5="http://schemas.microsoft.com/appx/manifest/desktop/windows10/5"  
  xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"  
  xmlns:desktop7="http://schemas.microsoft.com/appx/manifest/desktop/windows10/7"  
  xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"  
  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"  
  IgnorableNamespaces="uap rescap desktop desktop4 desktop7 com">  
  
	<Identity  
	  Name="MyApp.MyClsid"  
	  Publisher="MyPublisherInfo"  
	  Version="1.0.0.0" />  
  
	<Properties>  
		<DisplayName>MyApp</DisplayName>  
		<PublisherDisplayName>Publisher</PublisherDisplayName>  
		<Logo>Images\StoreLogo.png</Logo>  
	</Properties>  
  
	<Dependencies>  
		<!--<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />-->  
		<!--<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />-->  
  
		<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19000.0" MaxVersionTested="10.0.19000.0" />  
	</Dependencies>  
  
	<Resources>  
		<Resource Language="x-generate"/>  
	</Resources>  
  
	<Applications>  
		<Application Id="MyAppID"  
		  Executable="$targetnametoken$.exe"  
		  EntryPoint="$targetentrypoint$">  
			<uap:VisualElements  
			  DisplayName="MyApp"  
			  Description="SomeDescription"  
			  BackgroundColor="transparent"  
			  Square150x150Logo="Images\Square150x150Logo.png"  
			  Square44x44Logo="Images\Square44x44Logo.png">  
				<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />  
				<uap:SplashScreen Image="Images\SplashScreen.png" />  
			</uap:VisualElements>  
			<Extensions>  
  
				  
				<desktop4:Extension Category="windows.fileExplorerContextMenus">  
					<desktop4:FileExplorerContextMenus>  
						<desktop5:ItemType Type="*">  
							<desktop5:Verb Id="CMyVerb" Clsid="MyClsid" />  
						</desktop5:ItemType>  
					</desktop4:FileExplorerContextMenus>  
				</desktop4:Extension>  
				<com:Extension Category="windows.comServer">  
					<com:ComServer>  
						<com:SurrogateServer  DisplayName="MyShellExtension">  
							<com:Class Id="MyClsid" Path="ShellExtensionHandler.dll" ThreadingModel="STA"/>  
						</com:SurrogateServer>  
					</com:ComServer>  
				</com:Extension>  

                            <!-- I wasn't able to make this work but I am not even sure that's really needed-->  
				<!--<desktop:Extension Category="windows.fullTrustProcess" desktop7:Scope="machine"/>-->  
				<!--<desktop7:Extension Category="windows.approvedShellExtension" >  
					<desktop7:ApprovedShellExtension Name = "MyShellExtension" Clsid = "MyClsid" />  
				</desktop7:Extension>-->  
			</Extensions>  
		</Application>  
	</Applications>  
  
	<Capabilities>  
		<Capability Name="internetClient" />  
		<rescap:Capability Name="runFullTrust" />  
		<!--<uap4:CustomCapability Name="Microsoft.classicAppCompatElevated_8wekyb3d8bbwe"/>-->  
	</Capabilities>  
</Package>  
  

I tried to use the whole desktop7:ApprovedShellExtension but the installation fail when using those. I don't even think that's the solution since I have not changed the EnforceShellExtensionSecurity regkey according to https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-desktop7-approvedshellextension

Any ideas ?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Romain Braussen 1 Reputation point
    2022-12-12T17:50:04.537+00:00

    Turns out the manifest if fine, this is the Add-AppxProvisionedPackage/Remove-AppxProvisionedPackage commands who are... capricious.
    Since I was testing I was doing lots of uninstall/install, and even if the commands results say a reboot is not needed, it is definitely needed after each Uninstall/Install or the installation will be broken and won't work correctly (no matter the amount of subsequents reboots)

    So, AppxProvisionedPackage=> reboot.
    Remove-AppxProvisionedPackage=> reboot.

    And everything should work correctly.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.