NT service (setting Description string)

Discussion in 'Python' started by Larry Bates, Mar 2, 2004.

  1. Larry Bates

    Larry Bates Guest

    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
    Larry Bates, Mar 2, 2004
    #1
    1. Advertising

  2. "Larry Bates" <> writes:

    > 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


    There isn't any yet. Apparently you have to call the win32 api
    ChangeServiceConfig2() (but maybe it can also be done with the wmi
    module).

    Thomas
    Thomas Heller, Mar 3, 2004
    #2
    1. Advertising

  3. Larry Bates

    Larry Bates Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    Larry Bates, Mar 3, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. A.Mens

    HTML in service description

    A.Mens, Sep 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    285
    A.Mens
    Sep 11, 2004
  2. Tim Golden
    Replies:
    1
    Views:
    576
    Phipps Xue
    Mar 4, 2004
  3. A.Mens [RAPWare]

    HTML in service description

    A.Mens [RAPWare], Sep 10, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    112
    A.Mens [RAPWare]
    Sep 10, 2004
  4. A.Mens

    HTML in service description

    A.Mens, Sep 10, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    114
    A.Mens
    Sep 10, 2004
  5. Replies:
    0
    Views:
    150
Loading...

Share This Page