Also check the permissions on the problem users registry. I would
expect that to cause a different error, but it might be worth checking.<br><br>Kevin Horn<br><br><div class="gmail_quote">On Mon, Jun 23, 2008 at 2:25 PM, Roger Upole <<a href="mailto:rwupole@msn.com">rwupole@msn.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Mike Driscoll wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Mike Driscoll wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
In one of my login scripts for work, I run a query to see if the VNC<br>
service is running using the win32serviceutil module. The code for<br>
that I am using looks something like this:<br>
<br>
<code><br>
import win32serviceutil<br>
serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1]<br>
</code><br>
<br>
This works in 99.99% of cases. However, I have on user that keeps<br>
getting the following traceback:<br>
<br>
Traceback (most recent call last):<br>
File "\\ourServer\pathName\PostLogon.py", line 207, in ?<br>
serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1]<br>
File<br>
"\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py",<br>
line 479, in QueryServiceStatus<br>
hs = SmartOpenService(hscm, serviceName,<br>
win32service.SERVICE_QUERY_STATUS)<br>
File<br>
"\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py",<br>
line 81, in SmartOpenService<br>
name = _GetServiceShortName(name)<br>
File<br>
"\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py",<br>
line 62, in _GetServiceShortName<br>
skey = win32api.RegOpenKey(hkey, svc, 0, access)<br>
error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.')<br>
<br>
<br>
I used regmon to try and figure out what part of the Registry my code<br>
looks at and it appears to be looking for the "DisplayName" value in<br>
HKLM\SYSTEM\CurrentControlSet\Services\winvnc<br>
<br>
I cannot see a difference in this user's registry versus my own, which<br>
does not have this issue. However, I can duplicate the error by<br>
connecting to the user's PC's registry using the _winreg module and<br>
querying the "DisplayName" value, like this:<br>
<br>
QueryValue(key, 'DisplayName')<br>
<br>
Which give me this traceback:<br>
<br>
Traceback (most recent call last):<br>
File "<pyshell#14>", line 1, in <module><br>
QueryValue(key, 'DisplayName')<br>
WindowsError: [Error 2] The system cannot find the file specified<br>
<br>
But if I use use _winreg's EnumValue, I get this:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
EnumValue(key, 4)<br>
</blockquote></blockquote></blockquote>
('DisplayName', u'VNC Server', 1)<br>
<br>
What the!? Does anyone have any suggestions? Maybe a better way to get<br>
the information? I only need to know if the service is running or not,<br>
and if not, to start it.<br>
<br>
Thanks!<br>
<br>
<br>
</blockquote>
<br>
I forgot to mention that we use Windows XP, Python 2.4 and PyWin32<br>
version 210.<br>
<br>
Mike<br>
</blockquote>
<br>
You might want to try build 211. It uses the API function<br>
GetServiceKeyName instead of manually enumerating the<br>
registry.<br>
<br>
However, it sounds like you could have a corrupt registry key.<br>
Try reinstalling the service and see if that helps.<br>
<br>
Roger<br>
<br>
_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org" target="_blank">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
</blockquote></div><br>