mmatyas / pegasus-frontend

A cross platform, customizable graphical frontend for launching emulators and managing your game collection.
http://pegasus-frontend.org
Other
1.23k stars 111 forks source link

Shortcuts don't send Pegasus to the background #954

Open sofalzone opened 2 years ago

sofalzone commented 2 years ago

The issue

I noticed that, when launching .lnk files from the metafile, Pegasus returns from background right away. I see that this was discussed in the past, but it seems like it was resolved. Is it not possible to use .lnk files?

I can work around this issue by launching the target of the .lnk, but I can't this time, because I'm trying to launch a Windows Store app (Netflix and others). If I try to set the launch command to 'start netflix:' (a command that works from a Windows Terminal) it just crashes Pegasus. If I launch it from a batch file, Pegasus also returns when the Terminal window closes.

Is there a correct way to do this?

System info

Windows 10 Build 21H2

Pegasus version

Most recent

Pegasus log

Not relevant. Will provide if needed.

mmatyas commented 2 years ago

It should be possible to use .lnk files, and they were reported working before, but I'm not sure the same is true for Store apps. It should, at least, not crash; do you see anything related to that in the log file?

sofalzone commented 2 years ago

OK, when you use a .lnk to a Windows Store app, it opens the target app, but then Pegasus pops back up right away. It doesn't do this for standard Windows desktop applications (i.e. I tested Notepad++).

It only crashes when I set 'Lauch: start netflix:' or 'Lauch: "start netflix:" '. If I set "File: {batch file}", where {batch file} looks like:

start netflix: pause

It works as intended, but now there is a terminal open, and I have to go into Windows Task Manager to exit it before Pegasus comes back. If I take out "pause" Pegasus comes back right away like with the .lnk file. How is the "Launch" property used? This is not just a terminal or PowerShell command?

mmatyas commented 2 years ago

Hm so you can confirm it only fails with Windows Store apps, and not regular desktop apps? I'm not familiar with Store apps, could you post a screenshot of a Store app shortcut's properties window?

How is the "Launch" property used? This is not just a terminal or PowerShell command?

Pegasus launches programs. In this case, start is the program (one that comes with Windows) and the argument is netflix:. If you wish to launch a command prompt (cmd) or PowerShell you can do so as well.

sofalzone commented 2 years ago

Pegasus launches programs. In this case, start is the program (one that comes with Windows) and the argument is netflix:. If you wish to launch a command prompt (cmd) or PowerShell you can do so as well.

OK, so the Launch field is just designating a program (i.e. C:\Windows\System32\cmd.exe) and arguments? I always though it was an actual command in a system or programing language (e.g. Powershell, QT).

Here is the Target field from a shortcut for the Netflix app. The folder where they are kept is 'Shell:AppsFolder':

4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App

mmatyas commented 2 years ago

Yes, it launches executables with arguments – this means you can use PowerShell or cmd or any other shell. If you're familiar with how to run .lnk files from any of those, you can set up a launch command that uses them. For example, could you try cmd \c {file.path] as a launch command?

As for the shortcut, 4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App doesn't sound like a regular executable, but if it is, you should be able to call it like that directly from any command line.

sofalzone commented 2 years ago

I can't call "Shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App" as {file.path}. I ran the following launch command:

launch: cmd \c "L:\Console Games\System Programs\Netflix.lnk"

Pegasus is waiting on the cmd file. It won't run the shortcut; yet setting launch to the shortcut path alone does open Netflix, Pegasus just wakes up right away.

I noticed the same thing happens if you open the Epic Launcher. If I set the Launch command to the start menu shortcut for the Epic Launcher:

launch: "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Epic Games Launcher.lnk"

Epic opens, but Pegasus wakes up right away. The log file says:

[i] Executing command: [cmd,/q,/c,C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Epic Games Launcher.lnk] 2022-03-31T09:47:26 [i] Working directory: L:\Console Games\System Programs 2022-03-31T09:47:26 [i] Process 29028 started 2022-03-31T09:47:26 [i] ---------------------------------------- 2022-03-31T09:47:27 [i] ---------------------------------------- 2022-03-31T09:47:27 [i] The external program has finished cleanly

It will do this if I set the Launch command to the shortcut or EpicGamesLauncher.exe itself with:

launch: "C:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe"

I noticed that GOG and Retroarch do not behave the same way. It seems like EpicGamesLauncher.exe is just opening and closing right away, causing Pegasus to wake up, whereas gog.exe and retroarch.exe don't do this. This would make sense if EpicGamesLauncher.exe is just a launcher program opening the main program, and then closing out.

I'm guessing it's the same problem with the Windows store apps: the "4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App" target is really just a launcher program, which closes right after it opens the Netflix process. But with Epic, EpicGamesLauncher.exe does appear in the Task Manager while it is running. So maybe it auto closes right away after some system check or something and then reopens again?

Is Pegasus continuously checking for a running program when an external process is run? If so, maybe having it wait a second and checking again if it gets positive confirmation that the process is closed would prevent Pegasus from waking up when the external program is still running?

mmatyas commented 2 years ago

Ok, looks like we're one step closer. So launch: "L:\Console Games\System Programs\Netflix.lnk" does open Netflix, it's just Pegasus reappearing too soon?

So what we have so far is

Could you try the following launch commands?

Is Pegasus continuously checking for a running program when an external process is run?

Pegasus wakes up when Windows tells us that the launched program has finished. It the launched program too launches a program, but doesn't wait for its completion, that's not something Pegasus has knowledge about. For example, start by default returns instantly, but with /wait it should also wait for its own launched program to finish.

sofalzone commented 2 years ago

All of those launch commands fail in the same way. I get a Windows pop up window informing me that, "Pegasus Emulator Frontend has stopped working."