I have a cross-platform application created using Compose Multiplatform. I need to add it to SendTo menu (this menu is available in Windows Explorer when user right-clicked a file).
I've tried to find any options to implement it using Gradle. But there is no special options in nativeDistributions/windows.
I've also tried to implement it on application launch in main()
function with the code below:
val appPath = Paths.get("C:/Program Files/MyApp/MyApp.exe")
val sendToDir = Paths.get(System.getenv("APPDATA"), "Microsoft", "Windows", "SendTo")
val shortcutPath = sendToDir.resolve("MyApp.lnk")
Files.createLink(shortcutPath, appPath)
It doesn't work and throws an exception:
java.nio.file.AccessDeniedException: C:\Users\Me\AppData\Roaming\Microsoft\Windows\SendTo\MyApp.lnk -> C:\Program Files\MyApp\MyApp.exe
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsFileSystemProvider.createLink(WindowsFileSystemProvider.java:622)
at java.base/java.nio.file.Files.createLink(Files.java:1112)
How to create shortcut in Windows SendTo directory using Compose Multiplatform?