[python-win32] Querying the VNC Service fails sometimes

Kevin Horn kevin.horn at gmail.com
Mon Jun 23 21:51:59 CEST 2008


Also check the permissions on the problem users registry.  I would expect
that to cause a different error, but it might be worth checking.

Kevin Horn

On Mon, Jun 23, 2008 at 2:25 PM, Roger Upole <rwupole at msn.com> wrote:

>
> Mike Driscoll wrote:
>
>> Mike Driscoll wrote:
>>
>>> 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!
>>>
>>>
>>>
>> I forgot to mention that we use Windows XP, Python 2.4 and PyWin32
>> version 210.
>>
>> Mike
>>
>
> You might want to try build 211.  It uses the API function
> GetServiceKeyName instead of manually enumerating the
> registry.
>
> However, it sounds like you could have a corrupt registry key.
> Try reinstalling the service and see if that helps.
>
>        Roger
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080623/ad221f94/attachment.htm>


More information about the python-win32 mailing list