NT service (setting Description string)

L

Larry Bates

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
 
T

Thomas Heller

Larry Bates said:
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
 
L

Larry Bates

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')
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top