NT service (setting Description string)

Larry Bates lbates at swamisoft.com
Wed Mar 3 15:10:29 EST 2004


I found a way to do this that seems to make
sense.  You can modify the Description in
the registry using _winreg.  The value
is located at:

HMLM\SYSTEM\CurrentControlSet\Services\<servicename>

I then installed the code below in the main
program of the service (that gets executed
when the service is installed).  This way
the registry gets "fixed" every time the
service is installed or removed.  Seems to
work pretty well.

Thanks for the input from everyone.

Larry Bates


if __name__ == "__main__":
    import sys
    import _winreg
    #
    #  Following line handles install/remove/start/stop commands from the
command line
    #
    win32serviceutil.HandleCommandLine(AFRservice)
    try: cmd=sys.argv[1].upper()
    except: sys.exit()

    if cmd == 'INSTALL':
        print "Calling win32evtlogutil.AddSourceToRegistry for AFR
Application"

win32evtlogutil.AddSourceToRegistry('AFR','C:\Python22\Lib\site-Packages\win
32\servicemanager.pyd',
                                            'Application')

        #
        # Update the description of this service in the registry
        #

#---------------------------------------------------------------------
        # Open registry at the proper key

#---------------------------------------------------------------------
        regkey='SYSTEM\CurrentControlSet\Services\AFR'
        key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, regkey, 0,
_winreg.KEY_SET_VALUE)
        description='AFR provides automated routing for inbound faxes that
are ' \
                    'received by Castelle Faxpress fax server.  Faxes are
converted ' \
                    'to .PDF files and routed via SMTP email to users based
on ' \
                    'routing rules.'

        _winreg.SetValueEx(key, 'Description', 0, _winreg.REG_SZ,
description)

    elif cmd == 'REMOVE':
        print "Calling win32evtlogutil.RemoveSourceFromRegistry for AFR
Application"
        win32evtlogutil.RemoveSourceFromRegistry('AFR','Application')

"Larry Bates" <lbates at swamisoft.com> wrote in message
news:jJmdnfpaDewojtjdRVn-sQ at comcast.com...
> Anybody know what variable I need to define in my
> class to set the long description that shows up
> in the Services control panel applet?
>
> _svc_name_         holds the short name
> _svc_display_name_ holds the long name
> _svc_?????_        holds the description
>
> Thanks, Larry
>
>





More information about the Python-list mailing list