Windows, Python and Strings
Engel, Gregory
Gregory_Engel at csgsystems.com
Fri Jul 19 15:10:49 EDT 2002
I'm trying to update an NT/W2K service configuration (service written in Python) using win32service.ChangeServiceConfig. The following code runs without error:
>>> import win32serviceutil
>>> scm = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS)
>>> svc = win32service.OpenService(scm, "TestQueueMgrSvc", win32service.SC_MANAGER_ALL_ACCESS)
>>> svccfg = win32service.QueryServiceConfig(svc)
>>> svccfg
(16, 2, 1, u'"D:\\Python\\Lib\\site-packages\\win32\\PythonService.exe"', u'', 0, u'', u'LocalSystem', u'Test Queue Manager')
So, I have a handle to the service and can retrieve it's current configuration. Now I want to make this service dependant on MS SQL Server:
>>> win32service.ChangeServiceConfig(svc, svccfg[0], svccfg[1], svccfg[2], svccfg[3], svccfg[4], svccfg[5], 'MSSQLServer', 'LocalSystem', '', "Green Bar Queue Manager")
This also executes without error. When I look at the Registry, the value shows as "M S S Q L S e r v e r" rather than "MSSQLServer" so the dependency fails. If I use the MS tool, sc.exe:
sc config TestQueueMgrSvc depend= "MSSQLServer"
the Registry value correctly shows as "MSSQLServer". I've tried a number of approaches to resolving this with no luck. It doesn't appear to be a encoding issue.
The method requires a string parameter. The Registry stores the value as binary data. What am I missing? Is there something I don't understand about how to use this method?
Many Thanks.
C'ya,
Gregory Engel
Senior Software Engineer
Professional Services
CSG Systems, Inc.
9555 Maroon Circle
Englewood, CO 80112
Voice: 303-200-3426
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
My other computer is spongy gray matter.
More information about the Python-list
mailing list