Open straight-shoota opened 4 months ago
Given that shortcuts can be opened in cmd and powershell, I think it makes sense to wait for #13567 to be merged so that shell: true
actually works on Windows and subsequently opening shortcuts via Process.run
.
This has come up in Gitter chat.
Windows has shortcut files for launching programs or opening files. They have the extension
.lnk
and contain a reference to the target as well as some other properties (such as icon path, working directory etc.). A similar concept in Unix land are Desktop Entries (.desktop
).It's very common to use shortcuts on Windows (e.g. the Desktop is usually full of them) and users expect that they can open a shortcut to execute whatever it points to.
Shortcut files are not directly executable with
CreateProcessW
, so you cannot open a shortcut withProcess.run
(not even withshell: true
, which doesn't really do anything on Windows; ref #9030).They can be opened in
cmd
orpowershell
So going though
cmd /c
provides a solution, but it feels a bit hacky.The Win32 API has a native way to open files, which supports shortcuts:
ShellExecuteA
& co. These functions also provide other operations.The following example shows how the
ShellExecuteExW
function can be used to open a file (which may be a shortcut):I'm not sure what we could make out of this. Whether there can be a good and simple solution, or a one better than prefixing the file path with
cmd /c
. Maybe this issue can draw some ideas on the matter.