win32serviceutil won't start

N

Nikola Skoric

I have a very simple win32serviceutil script:
import win32serviceutil, time

win32serviceutil.StartService("burek", "localhost")

time.sleep(10)

exit()

It successfuly imports win32serviceutil, and chokes on StartService:
Traceback (most recent call last):
File "foobar.py", line 3, in ?
win32serviceutil.StartService("burek", "localhost")
File "C:\Python24\Lib\site-packages\win32\lib\win32serviceutil.py", line
399, in StartService
hs = SmartOpenService(hscm, serviceName, win32service.SERVICE_ALL_ACCESS)
File "C:\Python24\Lib\site-packages\win32\lib\win32serviceutil.py", line
76, in SmartOpenService
return win32service.OpenService(hscm, name, access)
pywintypes.error: (1060, 'OpenService', 'The specified service does not
exist as an installed service.')

What does that mean?
 
K

kyosohma

I have a very simple win32serviceutil script:
import win32serviceutil, time

win32serviceutil.StartService("burek", "localhost")

time.sleep(10)

exit()

It successfuly imports win32serviceutil, and chokes on StartService:
Traceback (most recent call last):
File "foobar.py", line 3, in ?
win32serviceutil.StartService("burek", "localhost")
File "C:\Python24\Lib\site-packages\win32\lib\win32serviceutil.py", line
399, in StartService
hs = SmartOpenService(hscm, serviceName, win32service.SERVICE_ALL_ACCESS)
File "C:\Python24\Lib\site-packages\win32\lib\win32serviceutil.py", line
76, in SmartOpenService
return win32service.OpenService(hscm, name, access)
pywintypes.error: (1060, 'OpenService', 'The specified service does not
exist as an installed service.')

What does that mean?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"

Looks like Microsoft thinks you mis-spelled it.

http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2000Msgs/3310.mspx?mfr=true

I would check and see if that service is installed on your PC. You can
go to Start --> Run and type services.msc

Scroll through there and see if your service is listed. You might
check to see if you can enable/disable it via that console as well.

Mike
 
N

Nikola Skoric

Dana Sun, 25 Nov 2007 13:52:35 -0800 (PST),
Looks like Microsoft thinks you mis-spelled it.

http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2000Msgs/3310.mspx?mfr=true

I would check and see if that service is installed on your PC. You can
go to Start --> Run and type services.msc

Scroll through there and see if your service is listed. You might
check to see if you can enable/disable it via that console as well.

Seems like I misunderstood Windows services (I'm porting UNIX daemon
to Windows so I'm thinking in UNIX terms). I didn't know I have to
_install_ a service before I _start_ it. How do I install a service?
 
W

Wolfgang Strobl

Nikola Skoric said:
Seems like I misunderstood Windows services (I'm porting UNIX daemon
to Windows so I'm thinking in UNIX terms). I didn't know I have to
_install_ a service before I _start_ it. How do I install a service?

Read chapter 18 of Python Programming on Win32 by Mark Hammond & Andy
Robinson. There is a paragraph on "Installing, Debugging and Running a
Python Service" starting on page 350. In short: use PythonService.exe
from the PyWin32 package. Then google for "smallestpythonservice".
 
K

kyosohma

Dana Sun, 25 Nov 2007 13:52:35 -0800 (PST),



Seems like I misunderstood Windows services (I'm porting UNIX daemon
to Windows so I'm thinking in UNIX terms). I didn't know I have to
_install_ a service before I _start_ it. How do I install a service?

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"

Sorry I didn't reply sooner. If you're creating a service based on a
Python file, check out the following links in addition to the book
Wolfgang mentioned:

http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html
http://www.thescripts.com/forum/thread595660.html
http://essiene.blogspot.com/2005/04/python-windows-services.html

That should get you started. Hope it helps!

Mike
 
N

Nikola Skoric

Dana Mon, 26 Nov 2007 08:50:23 -0800 (PST),
Sorry I didn't reply sooner. If you're creating a service based on a
Python file, check out the following links in addition to the book
Wolfgang mentioned:

http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html
http://www.thescripts.com/forum/thread595660.html
http://essiene.blogspot.com/2005/04/python-windows-services.html

That should get you started. Hope it helps!

Huh. Thank you guys a lot. I took a glance (albeit a rather long one)
and decided that my users will have to install cygwin if they want to
use my script. Service handling is just a bit to complicated (after
creating UNIX daemon with 2 consecutive forks), and I'm not going to
be paid for this :-D
 
K

kyosohma

Dana Mon, 26 Nov 2007 08:50:23 -0800 (PST),


Huh. Thank you guys a lot. I took a glance (albeit a rather long one)
and decided that my users will have to install cygwin if they want to
use my script. Service handling is just a bit to complicated (after
creating UNIX daemon with 2 consecutive forks), and I'm not going to
be paid for this :-D

--
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"

Yeah...a lot of things on Windows is just too complicated for its own
good. Every now and again you'll stumble across something that's
pretty elegant though.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top