I found out that ShellExecute(..., L"open", ...)
will choose to launch a shortcut instead of folder when the path is clearly a folder, when the folder and the shortcut has the same name besides .lnk
extension for the shortcut.
To repro:
- Create a
test.lnk
in desktop, link it to any exe
- Create a
test
folder in desktop
- Use this code:
ShellExecute(NULL, L"open", path_w.data(), nullptr, nullptr, SW_SHOW);
where path_w
is C:\Users\<UserName>\Desktop\test
ShellExecute
will correctly opens the folder if test.lnk
is changed to any other file extension, like text.txt
. This behavior is so unexpected and seems to not documented anywhere?