PlexConnect as Windows Service

I made a small change the the installation script below - address' the python not found issue...  

@echo off

set InstallerPath=%~dp0
set PlexConnectPath=%InstallerPath%…..
if “%PROCESSOR_ARCHITECTURE%”==“AMD64” goto x64
Set PythonPath=C:\Program Files\Python27
goto install
:x64
Set PythonPath=C:\Program Files (x86)\Python27
goto install

:install
“%PythonPath%python” “%PlexConnectPath%PlexConnect_WinService.py” install
cls
echo PlexConnect-Service installed!
pause

Hope this helps people out...

Just wanted to chime in and say this worked for me on Windows 8.1.  This, and removing "python" before the directory path.  In my case though, I had to modify the Python installation path, since I had not installed it to Program Files.

Hello,
 
i have a problem starting the service´, see screenshot

http://de.tinypic.com/r/2cilw2/8

I already searched for this error, but all i can find that something is wrong with the path in the Service-Registry. But it seems the path is right.

See three more helpful screenshots:

http://www.directupload.net/file/d/3547/q3fiiyl8_jpg.htm

http://www.directupload.net/file/d/3547/xkb5uvkv_jpg.htm

http://www.directupload.net/file/d/3547/ivgs2ax2_jpg.htm

It would be really nice if you can fix my problem, because this is the most wanted feature by me.

Hello,

the Problem was following: i had installed the 64bit Versions of python and pywin32.

When using 32-bit Version (even on 64bit-machine) it worked. Also deleted manually the Python27-Folder under C:\ when uninstalling the wrong python Version, and checked the registry for any python entry, and deleted it, before installing 32-bit Version.

Hi guys,

I'm having troubles making the windows service start automatically upon startup. The service itself is installed just fine and I'm able to start/stop it by either doing it through services.msc or using the included .bat files. But for some reason it will not start together with Windows.

I looked in the event logs and found this info that seems relevant:

The instance's SvcRun() method failed 
Traceback (most recent call last):
  File "C:\Program Files\Python27\lib\site-packages\win32\lib\win32serviceutil.py", line 835, in SvcRun
    self.SvcDoRun()
  File "C:\Program Files (x86)\PlexConnect-master\PlexConnect_WinService.py", line 40, in SvcDoRun
    running = PlexConnect.startup()
  File "C:\Program Files (x86)\PlexConnect-master\PlexConnect.py", line 73, in startup
    param['IP_self'] = getIP_self()
  File "C:\Program Files (x86)\PlexConnect-master\PlexConnect.py", line 29, in getIP_self
    s.connect(('1.2.3.4', 1000))
  File "C:\Program Files\Python27\lib\socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: (10051, 'En socket\xe5tg\xe4rd f\xf6rs\xf6kte utf\xf6ras till ett n\xe4tverk som inte g\xe5r att kontakta') 
%2: %3
 
The error line at the bottom basically says "A socket operation was attempted to an unreachable network".
I have tried looking through the files mentioned but I'm out of my league here. I did however react to this part: s.connect(('1.2.3.4', 1000))
Is that supposed to be that way?
 
You guys have done an outstanding job with PlexC btw, now if I could only make this work it would be perfect...

Ok guys, had the service working ok on W7. Recently the service refuses to start manually or automatically, just says when done manually through the service GUI that’s it started then stopped. This may happen automatically to some services if not in use. Any ideas? Uninstalled and reinstalled using the batch files

Ok so it seems the solution was way simpler than I first thought. Upon boot the service started up before my WiFi had had time to connect so of course it wouldn't find a network. Sigh.

Ok guys, had the service working ok on W7. Recently the service refuses to start manually or automatically, just says when done manually through the service GUI that's it started then stopped. This may happen automatically to some services if not in use. Any ideas? Uninstalled and reinstalled using the batch files

Have you checked Event viewer logs?

 
Have you checked Event viewer logs?


Strangely, they show nothing!

Removed python in front of %plexconnectpath%plexconnect_winservice.py" and did below and WOLA finally works after a few more grey hairs later!

it didn't work at first. I opened up task manager (I'm on windows 7 x64), by hitting ctrl alt del and then selected the services tab. Then I clicked on the admin icon labeled services in the bottom right which brought up a windows with all possible service, whther they're currently running or not. I found plexconnect in there, right clicked and hit properties and set the startup type to automatic. That did it, now it works fine.

I was having issues with wifi not being connected at startup and the service causing issues so I set the service to automatic (delayed start) in services.msc and now when I reboot it works perfectly it just waits about 90 second prior to starting after a reboot. Which is not a problem for me. If you are able to start the service manually in services.msc but it doesn't seem to start with automatic set then try automatic (delayed start).

Thanks for the taking the time to develop this utility.

Note: I am running Win 7 Ultimate - 64-bit.  I did install the 64-bit versions of all requisite software.  PlexConnect does run when I manually start it (not as service) and I'm able to connect to my PMS from my AppleTV and play movies from my library.  The only issue I'm having is getting PlexConnect to run as service.

I am able to get the PlexConnect-Service installed.  However, when I attempt to start it I get the following message:

"The PlexConnect-Service service on Local Computer started and then stopped.  Some services stop automatically if they are not in use by other services or programs."

Tried triaging this as best I could.  I did add my Python27 directory (c:\Python27) to the path environment variable.  Verified that I can invoke the python interpreter from command prompt from any directory.

Tried playing around with Automatic (delayed) - no luck (I assumed this result, since I can't start it manually).

Noticed that when starting PlexConnect from command-line, it reports the Host OS as win32.  I do have 64-bit Windows, 64-bit Python, 64-bit Python Extensions.  Seems like I have a correct 64-bit installation.

Are there some log files that could be inspected to see what is failing?  Any assistance would be appreciated.

Thank you.

Checked the event viewer and see this:
 

The instance's SvcRun() method failed 
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\win32\lib\win32serviceutil.py", line 835, in SvcRun
    self.SvcDoRun()
  File "C:\Program Files\PlexConnect-master\PlexConnect_WinService.py", line 40, in SvcDoRun
    running = PlexConnect.startup()
  File "C:\Program Files\PlexConnect-master\PlexConnect.py", line 89, in startup
    proxy.start(initProxy)
  File "C:\Python27\lib\multiprocessing\managers.py", line 502, in start
    self._address = reader.recv()
EOFError 
%2: %3
 
As stated above, starting PlexConnect from command works fine:
C:\Program Files\PlexConnect-master>PlexConnect.py
12:18:22 PlexConnect: ***
12:18:22 PlexConnect: PlexConnect
12:18:22 PlexConnect: Press CTRL-C to shut down.
12:18:22 PlexConnect: ***
12:18:22 PlexConnect: started: 12:18:22
12:18:22 PlexConnect: Version: 0.5-dev
12:18:22 PlexConnect: Python: 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500
 64 bit (AMD64)]
12:18:22 PlexConnect: Host OS: win32
12:18:22 PlexConnect: PILBackgrounds: Is PIL installed? False
12:18:22 PlexConnect: IP_self: nnn.nnn.nnn.nnn
12:18:22 DNSServer: started: 12:18:22
12:18:22 DNSServer: ***
12:18:22 DNSServer: DNSServer: Serving DNS on nnn.nnn.nnn.nnn port 53.
12:18:22 DNSServer: intercept: ['trailers.apple.com'] => nnn.nnn.nnn.nnn
12:18:22 DNSServer: restrain: ['mesu.apple.com', 'appldnld.apple.com', 'appldnld
.apple.com.edgesuite.net'] => 127.0.0.1
12:18:22 DNSServer: forward other to higher level DNS: 8.8.8.8
12:18:22 DNSServer: ***
12:18:22 WebServer: started: 12:18:22
12:18:22 WebServer: ***
12:18:22 WebServer: WebServer: Serving HTTP on nnn.nnn.nnn.nnn port 80.
12:18:22 WebServer: ***
12:18:22 WebServer: started: 12:18:22
12:18:22 WebServer: ***
12:18:22 WebServer: WebServer: Serving HTTPS on nnn.nnn.nnn.nnn port 443.
12:18:22 WebServer: ***

Gave up trying to debug python and get the service installation utility working on my Windows 7 system.

Ended up using NSSM to get PlexConnect installed as a service - what a fantastic tool.  Extremely easy to use.  I had PlexConnect running as a service in minutes.

You can find it here: http://nssm.cc/release/nssm-2.24.zip

Invocation: nssm install PlexConnect-Service

Parms I used:

Path: C:\Python27\python.exe

Startup directory: C:\Program Files\PlexConnect-master

Arguments: PlexConnect.py