install-unity icon indicating copy to clipboard operation
install-unity copied to clipboard

Add admin popup on Windows when running install-unity

Open ewilh opened this issue 3 years ago • 1 comments

Added app.manifest for admin privilege request. Running install-unity will now prompt user for admin credentials. The downside is that not all methods in install-unity require admin consent, but it will ask for it regardless. I haven't changed anything from the default app.manifest except on line 19 with the code: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> There might be more changes needed in the app.manifest before it's ready for production.

I also added RuntimeIdentifiers so that I'm able to publish the app. I'm not quite sure how you're able to publish on Windows without this.

I noticed that Unity was firstly installed on the path Unity {major}.{minor}, and I don't necessarily like that approach. Most Unity users (and especially those who use this tool) will install multiple different Unity versions on {major}.{minor}. I recommend removing this both for Windows and Mac, but here I've only removed it for Windows.

major_minor

ewilh avatar Sep 23 '22 06:09 ewilh

Note that after the admin pop-up, a separate shell window with admin privileges will open. When the code is finished running, the admin shell window will close immediately, thus preventing the user from seeing the output. A solution is to add a "Press any key to exit" on Windows only. Something like this:

  public static int ExitAfterUserInput(int exitCode)
  {
      Console.WriteLine("Press any key to exit");
      Console.ReadLine();
      return exitCode;
  }

ewilh avatar Sep 23 '22 07:09 ewilh