[3rd Party tool] Run Plex as Windows Service

I use WHS v1 and wanted to make Plex Media Manager run as a service so i wrote a AutoIT script to do just that! Below you will find the script and the source files to go with it.



Download: http://preytontech.com/site/download.php?view.8

Source: http://preytontech.com/site/download.php?view.9



Installation:

[list=1]

[]Extract the PMS_Service_1.0.zip to a folder of your choice

[
]Open Configuration.ini in notepad, edit the lines user= and pass= to your servers admin account (or the account you have been running plex as)

[]Open a Command Prompt (Start > run > type in CMD and hit enter)

[
]Drag the PMSService.exe into the command prompt to insert the path to the script, enter in -i after the script name Example: C:\plexscripts\PMSService.exe -i

[]Hit Enter, Reboot

[/list]



Un-Installation:

[list=1]

[
]Drag the PMSService.exe into the command prompt to insert the path to the script, enter in -u after the script name Example: C:\plexscripts\PMSService.exe -u

[]Hit Enter

[/list]



Notes:

[list]

[
]This should work with all versions of windows

[]This will support both x86 and x64

[
]I am thinking of making this into a WHS Plugin.

[]This is my first pass at a public version of this script so if there are issues let me know.

[
]The Script logs some basic information in a log file where you have the exe sitting.

[/list]



1st steps to Troubleshooting:

[list]

[]If you can see the Media Manager running in the task manager but clients cannot connect Remote desktop into your server and try opening http://localhost:32400/ Or see if the server is communicating with My plex if you had it setup before running as a service.

[
]Check the log file to see if the script is having to re launch the media server alot

Look for errors in Plex’s Logs

[/list]

I checked the PMSservice log and it seems to be attempting to start PMS numerous times:



20111111 182015 [3756] >> script started

20111111 182015 [3756] >> InstallService(): Installing service, please wait

20111111 182015 [3756] >> InstallService(): Installation of service successful

20111111 183128 [4712] >> script started

20111111 183128 [4712] >> Finding Plex Media Server

20111111 183128 [4712] >> Starting Plex Media Server

20111111 183149 [4712] >> Plex Media Server not running.

20111111 183149 [4712] >> Starting Plex Media Server

20111111 183216 [4712] >> Plex Media Server not running.

20111111 183216 [4712] >> Starting Plex Media Server

20111111 183240 [4712] >> Plex Media Server not running.

20111111 183240 [4712] >> Starting Plex Media Server

20111111 183244 [4712] >> Plex Media Server not running.

20111111 183244 [4712] >> Starting Plex Media Server



This goes on and on, until I remote desktop into my server, at which time Plex is launched and all works as it should. But then, this defeats the purpose of running Plex as a service if I have to login to my server. (and once I logout, again, Plex is not working).



Doing some more investigating:

When not logged into the server, using the Dashboard to access the server (and the remote launcher and advance admin addins), I can see that the service PlexMediamanager is not running and in manual mode. I switch to it auto and start the service. The Processes PMSservice is running and the Plex Media Server also, but no PlexScriptHost running. Logging into the server via Remote Desktop, then corrects everything. (again Plex is started by logging in).



Before logging in, Plex created this log file:

Nov 12, 2011 11:29:21 [640] INFO - LANGID = 0x409

Nov 12, 2011 11:29:21 [640] DEBUG - LoadMUILibraryW(0) returned 0x73A30002

Nov 12, 2011 11:29:21 [640] INFO - Windows version 6.1 (Build 7601)

Nov 12, 2011 11:29:21 [640] INFO - 2 1297 MHz processor(s): Architecture=0, Level=16, Revision=1539

Nov 12, 2011 11:29:21 [640] INFO - PROCESSOR_IDENTIFIER=AMD64 Family 16 Model 6 Stepping 3, AuthenticAMD

Nov 12, 2011 11:29:21 [640] INFO - Plex Media Server v0.9.5.0-dc1de23

Nov 12, 2011 11:29:21 [640] DEBUG - Opening database session to library, SQLite 3.6.23.1, threadsafe=1

Nov 12, 2011 11:29:21 [6004] ERROR - Shell_NotifyIcon(NIM_ADD, NIM_SETVERSION) failed: 0x0

Nov 12, 2011 11:29:21 [6004] ERROR - FATAL ERROR: TrayIcon::Create failed

Nov 12, 2011 11:29:21 [640] DEBUG - Opening database session to library, SQLite 3.6.23.1, threadsafe=1

Nov 12, 2011 11:29:21 [640] DEBUG - Opening database session to library, SQLite 3.6.23.1, threadsafe=1

Nov 12, 2011 11:29:21 [640] DEBUG - Opening database session to library, SQLite 3.6.23.1, threadsafe=1

Nov 12, 2011 11:29:21 [640] DEBUG - Opening database session to library, SQLite 3.6.23.1, threadsafe=1

Nov 12, 2011 11:29:27 [640] ERROR - WinPreferences: GetRegistryValue for LocalAppDataPath failed: 0x3fa

Nov 12, 2011 11:29:27 [640] DEBUG - Opening database session to library, SQLite 3.6.23.1, threadsafe=1

Nov 12, 2011 11:29:27 [640] ERROR - WinPreferences: GetRegistryValue for LocalAppDataPath failed: 0x3fa

Nov 12, 2011 11:29:27 [640] DEBUG - Opening database session to library, SQLite 3.6.23.1, threadsafe=1



Hope this gives you more clues as to what is going on. To me, it seems that Plex cannot create the trayicon and all goes downhill from here.

Yes after spending some time on it tonight it is due to the fact there is no user logged onto the system.



I never saw the issue since My server is also my living room TV’s client box so i have the Media manager running as Administrator and a auto login limited account named “MediaCenter” that runs the client on the TV. When i logged out my MediaCenter user i had the issue you describe, So for some reason plex does not even care if it cant make the icon as the user its running as it just wants to make a icon. remote desktop does not seem to fix it for me. I am looking into a way to trick the Plex Server into thinking it did create the Tray icon.

There is a thread about this here: http://forums.plexapp.com/index.php/topic/23711-running-pms-as-a-service-in-whs/

I guess there is no solution to this without PMS code being modified to enable running headless as many other applications are able to. I have used srvany successfully for quite a few applications, but won’t work with PMS :frowning:



I only hope that the developers will have time to adress this now that they have released Laika…

I do wish the authors of Plex could just add a command line argument to create the tray icon or not. This way, would could launch Plex automatically with software as yours, or even use the task scheduler to launch it at boot up of a server. I don’t see this as a very difficult thing to add, until they could properly code Plex as a service for Windows.

Has anybody tried AlwaysUp?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.