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.