https://stackoverflow.com/a/34737590/14113049
Using the above answer I was able to create a folder shortcut in the navigation pane on my host machine (Windows 11) but it won't work on a fresh install of Windows 10 or 11 in a virtual machine. It doesn't work in the VMs regardless of if my app is running elevated or not.
I've also tried other methods of doing this including running a batch file from a cmd.exe process launched by my app: https://stackoverflow.com/a/34595293/14113049
or by importing a premade .reg file with reg.exe import or regedit.exe /S launched from my app: https://www.codeproject.com/tips/1116313/creating-a-link-in-the-left-pane-of-the-file-explo
These methods exhibited the same behavior as the native C# code. They work on my host machine but not on my fresh VMs. Strangely when running the .bat or .reg file on the VMs directly (not through my C# program) it works and the folder shows up in the Navigation Pane of Windows Explorer after a reboot where it should be.
I'm stumped on this. I can't help but think it's some sort of permissions issue but that doesn't make much sense either because the keys are in HKEY_CURRENT_USER which supposedly the current user has full access to by default and again I've already tried running it elevated with no luck.
CodePudding user response:
My app was packaged with MSIX and the issue was due to the way registry works in MSIX packages. Unless otherwise specified MSIX virtualizes the registry and redirects all writes to the virtualized registry. To disable redirection add the following to your MSIX Package.appxmanifest:
<Package xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6">
<Properties>
<!-- Disabling File System Write Virtualization may not be necessary but this is how you turn that off as well -->
<desktop6:FileSystemWriteVirtualization>disabled</desktop6:FileSystemWriteVirtualization>
<desktop6:RegistryWriteVirtualization>disabled</desktop6:RegistryWriteVirtualization>
</Properties>
<Capabilities>
<rescap:Capability Name="unvirtualizedResources" />
</Capabilities>
</Package>
Note that your app is unlikely to get accepted to the Microsoft Store unless you provide a good reason for requiring these capabilities.