MultiMC / Launcher

A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once
https://multimc.org/
Other
4.31k stars 883 forks source link

Exit MultiMC after Instance has closed #1873

Closed Zocker1999NET closed 7 years ago

Zocker1999NET commented 7 years ago

System Information

MultiMC version: 0.5.0-develop-971

Operating System: Windows 10 Pro - Build 16179.1000

Summary of the problem:

MultiMC stays open after closing any instance whether the instance was started with the MultiMC UI or with a shortcut using the command "-l myInstance". There is no setting to let MultiMC automatically close after an instance was exited without any error.

The problem is, for example, if I add MultiMC to my Steam Library and configure the launch settings to start my main instance automatically, Steam does recognize MultiMC as the game. The Overlay and Configurations for the Steam Controller work perfect, but after closing Minecraft, Steam does not see this and so it is showing my friends I am playing Minecraft until MultiMC is closed as well.

What should be added:

There should be added an option to enable a feature like this. It would also be great if MultiMC could close itself only if the instance was launched with the command line.

QuImUfu commented 7 years ago

i think this is a good suggestion for an additional command line switch. A workaround for the moment would be adding

Taskkill /IM MultiMC.exe 

as a post exit command. (hope this works, can't test it) This would however lead to MultiMC exiting even if the instance is started out of MultiMC.

If you want to make it more advanced and make it exit only if started over steam you could start MultiMC with a script that creates some flag file before starting MultiMC and have another script as post exit command that exits MultiMC only if the flag file exists and deletes the flag file. I can sadly not make and post scripts for this as i am not using Windows.

Zocker1999NET commented 7 years ago

Your idea is great, but it does not work with any modification as I had expected it. MultiMC does not want to close because it thinks an instance is still running because the post-exit command is seen as part of the instances. I have added the parameter /F to force MultiMC to exit. Now it works as expected.

Complete post-exit command is now in my case: taskkill /F /IM MultiMC.exe I think it is not even bad if MultiMC closes even after I had started the instance out of MultiMC so that is no problem for me.

Thanks for your workaround!

peterix commented 7 years ago

So, some ideas and issues related to this:

The reason why a main window is even created when launching a single instance directly is that there's still too much of the application logic attached to it. I was getting crashes without it and wanted to release 0.5.0 ASAP.

peterix commented 7 years ago

Alright, I fixed it up a bit.

Effectively, it should work. Try the develop version :)

peterix commented 7 years ago

MultiMC will now exit after an instance is closed, as long as there are no windows left behind. It will not create a main window, unless you actually launch it normally. Direct launch of instance does not - by default - not create an instance window. This has to be enabled in the settings, or the instance has to crash.

I consider this a good enough solution until MultiMC can track running instances even through its own restart.

Closing {#1873, #1874, #1875}