[python-win32] How to determine whether program running asservice?
Mark Hammond
mhammond at skippinet.com.au
Fri Sep 10 07:53:09 CEST 2004
> > > What's the canonical way to programmatically determine whether a
> > > pywin32-based Python program is running as a Windows service or as
> > > a regular process?
> >
> > I don't see one :( I would be happy to add one - eg,
> > sys.serviceexecutable being set to the host executable when
> > launched as a service.
>
> Why not something like this:
> servicemanager.RunningAsService() -> bool
Yes, I agree - see my other post :) I just didn't think it through enough
at the time - I recently stuck a sys.isapidllhandle in a new py2exe
extension, and sys.frozendllhandle has existed for some time. I just had
sys on the mind :)
I think a simple attribute should be OK - no need for a function call. As I
implied in my other mail, a simple way of knowing if you are being run for
debugging may also help - at the moment you would need to imply that if
is_service is False, you are being debugged - but that isn't necessarily
true.
Mark
More information about the Python-win32
mailing list