-1

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.

  • In the case where the .bat fails, does it write to the registry or not? – Anders Aug 12 '22 at 07:58
  • @Anders It does appear to write to the registry however no folder appears in File Explorer even after reboot, unless the .bat was run manually. – SilentNightx Aug 12 '22 at 21:21
  • I've discovered when my app is installed on the VM using a .msixbundle it does not work however when I move the .exe over and run it directly it works. I still don't know why though. – SilentNightx Aug 13 '22 at 06:25

1 Answers1

1

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.