TechieGuy12 / PlexServerAutoUpdater

Automatically update Plex when running the Plex service.
MIT License
118 stars 10 forks source link

Plex 64bit installation not found #55

Closed daeks closed 1 year ago

daeks commented 1 year ago

Good day,

after updating plex to 64bit and the updater to 0.2.1.0, I cant find the installation anymore. It gives following error:

2022-10-23 10:59:33 Getting windows user. 2022-10-23 10:59:33 Checking if user is an administrator. 2022-10-23 10:59:33 Initializing the silent update. 2022-10-23 10:59:33 The Plex Media Server is not installed. 2022-10-23 10:59:33 Plex does not appear to be installed as the Plex installation folder could not be determined. 2022-10-23 10:59:33 bei TE.Plex.MediaServer.Initialize() bei TE.Plex.MediaServer..ctor(String logPath, MessageChangedEventHandler handler) bei TE.Plex.SilentUpdate.Initialize(String logPath) bei TE.Plex.Program.Main(String[] args)

what can I do? I have not installed Plex in ProgramFiles, the registry entries are set correctly

TechieGuy12 commented 1 year ago

The updater will do three checks for the Plex installation folder:

  1. Check the default "Program Files (x86)" or "Program Files" - it determines the location using the %ProgramFiles(x86)% and %ProgramW6432% environment variables.
  2. Checks the Plex process to determine the installation path.
  3. Queries the MSI component associated with the Plex executable.

Apparently, all three checks returned null, from what I can tell from the log.

Plex is running without issues on the machine? Where is Plex installed?

If needed, I can see about adding additional logging to help narrow down the issue.

daeks commented 1 year ago

Yes, plex runs well since a few years on that machine with any issue - I just switched from x86 to x64 a few weeks ago.

it is located under D:\server\plex\bin and if I take a look into the registry, I can find the "InstallFolder" entry under HKEY_CURRENT_USER\Software\Plex, Inc.\Plex Media Server, pointing to the right directory.

Also PlexService is running fine.

TechieGuy12 commented 1 year ago

Thanks. My installs are in the default location, and since I don't have that registry value the install may only add it if a custom location is specified.

It should be any easy fix. I'll let you know when I create a new release.

TechieGuy12 commented 1 year ago

Can you try the 0.2.1.1-beta.1 release?

daeks commented 1 year ago

thank you very much, unfortunately not - it looks like that it tries to lookup the service user, which is a different one executing the update.

TechieGuy12 commented 1 year ago

Yes, it always did that. The one executing the update needs to be an administrator on the machine, but the user running the Plex service does not need to be an administrator.

If the user that is running the service is different, as in your case and mine, then the updater will need to lookup the user so it an read the correct registry keys - since the keys are in the HKEY_CURRENT_USER hive.

I need to read the Plex user's HKEY_CURRENT_USER hive for things like the Plex token, and whether Plex Pass downloads are enabled. This is the hive read by the Plex server, and could be different than the administrator's Plex registry keys setup during the installation when Plex is started the first time.

Now, the issue could be that if you are looking at the HKEY_CURRENT_USER hive of the administrator, and not the Plex service user, and you see the InstallFolder value that isn't in the Plex service user's Plex registry key, then that could be an issue. The easiest solution would be to export that InstallFolder value from the administrator registry key, and then import it into the Plex service user's registry key so that value exists.

daeks commented 1 year ago

The easiest solution would be to export that InstallFolder value from the administrator registry key, and then import it into the Plex service user's registry key so that value exists.

Thank you very much for the explanation, I fully understood it - another easy solution would be just to look into the registry of the user executing the update. As far as I have seen you have introduced a settings file, so adding the install location there would also be an option. Extracing the registry key, reimporting it for the service user just to start the updater sounds not right as the service user will anyhow not have the priviledge to execute the update, it will be the user calling the updater.

TechieGuy12 commented 1 year ago

You can add the PlexInstallLocation key to the configuration file and specify the full path to the Plex install location as the value. The updater will read this value first to get the installation location.

Release 0.2.1.1-beta.2 has the change.

daeks commented 1 year ago

That looks good :) thank you very much. I have specified the path and now it is working fine again.

TechieGuy12 commented 1 year ago

Great. I'll close the issue and release the update.