pegasus-frontend icon indicating copy to clipboard operation
pegasus-frontend copied to clipboard

Shortcuts don't send Pegasus to the background

Open sofalzone opened this issue 3 years ago • 8 comments

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.

sofalzone avatar Mar 09 '22 21:03 sofalzone

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?

mmatyas avatar Mar 10 '22 15:03 mmatyas

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?

sofalzone avatar Mar 10 '22 19:03 sofalzone

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.

mmatyas avatar Mar 18 '22 13:03 mmatyas

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

sofalzone avatar Mar 30 '22 12:03 sofalzone

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.

mmatyas avatar Mar 30 '22 15:03 mmatyas

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?

sofalzone avatar Mar 31 '22 14:03 sofalzone

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

  • launch: start netflix: crashes
  • launch : <batch file> with start netflix: in it works, but opens a command prompt
  • launch: <.lnk file> works but Pegasus reappears instantly

Could you try the following launch commands?

  • launch: 4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App
  • launch: start /wait 4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App
  • launch: start /wait netflix:
  • launch: start /wait "L:\Console Games\System Programs\Netflix.lnk"

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.

mmatyas avatar Mar 31 '22 14:03 mmatyas

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."

sofalzone avatar Apr 16 '22 15:04 sofalzone