Hi,
In one of my login scripts for work, I run a query to see if the VNC
service is running using the win32serviceutil module. The code for that
I am using looks something like this:
<code>
import win32serviceutil
serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1]
</code>
This works in 99.99% of cases. However, I have on user that keeps
getting the following traceback:
Traceback (most recent call last):
File "\\ourServer\pathName\PostLogon.py", line 207, in ?
serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1]
File
"\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py",
line 479, in QueryServiceStatus
hs = SmartOpenService(hscm, serviceName, win32service.SERVICE_QUERY_STATUS)
File
"\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py",
line 81, in SmartOpenService
name = _GetServiceShortName(name)
File
"\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py",
line 62, in _GetServiceShortName
skey = win32api.RegOpenKey(hkey, svc, 0, access)
error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.')
I used regmon to try and figure out what part of the Registry my code looks at and it
appears to be looking for the "DisplayName" value in
HKLM\SYSTEM\CurrentControlSet\Services\winvnc
I cannot see a difference in this user's registry versus my own, which does not have this
issue. However, I can duplicate the error by connecting to the user's PC's registry using
the _winreg module and querying the "DisplayName" value, like this:
QueryValue(key, 'DisplayName')
Which give me this traceback:
Traceback (most recent call last):
File "<pyshell#14>", line 1, in <module>
QueryValue(key, 'DisplayName')
WindowsError: [Error 2] The system cannot find the file specified
But if I use use _winreg's EnumValue, I get this:
EnumValue(key, 4)
('DisplayName', u'VNC Server', 1)
What the!? Does anyone have any suggestions? Maybe a better way to get the
information? I only need to know if the service is running or not, and if not,
to start it.
Thanks!
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32