You are here

PortableApps.com Platform cannot launch .lnk shortcuts as apps (possible solution)

1 post / 0 new
filips
Offline
Last seen: 1 year 9 months ago
Joined: 2022-12-28 08:04
PortableApps.com Platform cannot launch .lnk shortcuts as apps (possible solution)

I created a portable app that uses a .lnk shortcut that launches another EXE as an app entrypoint (why I need this is explained below). When launched directly from File Explorer, the shortcut works correctly. PortableApps.com Platform also detects the app and displays it in the menu. However, when I try to launch it from the menu, nothing happens (the menu disappears, but the app does not start).

I checked the source code of the PortableApps.com Platform to see how it launches apps:

// If no baddies and we should run it, we start the app
if (bolAppAppearsClean and bolRunApp) then
begin
    if (bolAdmin) then
        ShellExecute(0, 'runas', PChar(strFilePath+#0), Nil, PChar(strWorkingDirectory+#0), SW_SHOWNORMAL)
    else
        ShellExecute(0, 'open', PChar(strFilePath+#0), Nil, PChar(strWorkingDirectory+#0), SW_SHOWNORMAL);
    Result:=true
end
else
    Result:=false;

(From PortableApps.com Platform 23.0, main.pas, line 7520)

After some research, it appears that launching .lnk shortcuts using ShellExecute with lpOperation open does not work and that lpOperation should be set to NULL instead (source 1, source 2, source 3). Is it possible to modify PortableApps.com Platform to check if the target application is .lnk and set lpOperation to NULL in that case?

Now, why do I think supporting shortcuts would be useful? First, it appears some users already tried to do this in the past to have both portable and installed apps in one place. Additionally, I would need this for a project I'm working on. This project allows users to install PWAs in Firefox. When PortableApps.com integration is enabled, it should create a new "portable app" for that PWA with a shortcut that just launches the main executable (which is also packaged as a portable app). Users should then be able to see and launch this portable PWA from the PortableApps.com Platform menu. I cannot create a custom wrapper EXE because the app needs to be generated on-the-fly when the user installs it. I also cannot use .bat file or similar script because then it opens a console window and cannot be pinned to the main start menu. So, I think using .lnk shortcuts would work the best (as long as the PortableApps.com Platform adds support for them).