Close Unity Hub when exiting the editor (windows)

General discussion of the House Party CSC, or get help making your own story.
Forum rules
Please follow all Eek! Forum rules.
Post Reply
Partylion
Posts: 4
Joined: Mon Nov 29, 2021 11:07 am

Close Unity Hub when exiting the editor (windows)

You have worked on your arousing story for eons, like almost 5 minutes.
You know it's perfect now so you export it, close the Unity editor, fire up House Party and load into a new game.
But right at the moment when Leah pulles out her Katana in order to cut your head off, you realize ...something is wrong.
Like everybody with some kind of sense for quality you obviously play the game in 16k resolution @288hz,
but the game only runs at 60fps.
Yea, you did not close the Unity Hub after closing the editor which eats 50% of your pc's resources and you wish,
they would have added an option to close it automatically when you quit the editor.

For everybody who does not know how to do that, I will tell you. (windows 10)
(don't copy the spaces in front of the lines, I tell you to copy/paste, I just added them for aesthetic reasons)

First you need to enable "application start logging":

Start and enter secpol.msc into the Run box
Navigate to Local Policies -> Audit Policy
Double Click Audit process tracking and enable Success

create an empty text document and copy/paste the following into it and save.

taskkill /IM "Unity Hub.exe" /F /T

Name it "name.bat" for example: "QuitUnityHub.bat" and put it at any place you want (except the windows Program Files folders)
I suggest you just put it in your Unity projects folder.

Now open the "Task Scheduler":
create a new task
On the General Tab, give the task a name / Configure for: Windows 10
On the Triggers tab, create a new trigger,
and choose "Beginn the task: On an event" as the trigger
Choose "Custom", and click "Edit Event Filter"
Select the "XML" tab and check the box "Edit query manually"

Copy and paste the following code into the field and hit "OK"
(you may need to adjust the installation path of the unity editor ...this is the default one)

<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">*[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and Task = 13313 and (band(Keywords,9007199254740992)) and (EventID=4689)]]
and
*[EventData[Data[@Name='ProcessName'] and (Data='C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Unity.exe')]]
</Select>
</Query>
</QueryList>

Back at the "Edit Trigger Window" hit "OK" again.

Change to the "Actions" tab and click "New..."

"Action: start a program"

Copy and paste the following into the "Program/script:" field:

C:\Windows\System32\cmd.exe

Copy and paste the following into the "Add arguments (optional):" field:
(adjust the path and name)

START /MIN CMD.EXE /C "C:\Users\UserName\Unity\QuitUnityHub.bat"

Hit "OK"
Hit "Ok"
Close the "Task Scheduler"



Now everytime you close the Unity Editor the Unity Hub and every child process will get taskkilled.

Enjoy House Party, crystal clear and with stutterfree 288 fps, in 16k resolution :D
Post Reply