Hello team.

I've done some more testing on this I'm really hoping there is an answer to what I'm trying to do. Maybe there is something I'm overlooking or don't understand about the registry and permissions on Windows 7 and how the _winreg library works.

As shown below, I'm trying to retrieve a value from a registry key. The app that is writing the key appears to be coded so that Windows writes the key to the VirtualStore area of the registry. Everything I've read so far says application programs, if the permissions and access is coded correctly, should not access the VS keys directly.

As a test, I put the following two lines in my program:
-----
# ConnKey = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Interface Software\ConnMgr', 0, KEY_READ) ConnKey = OpenKey(HKEY_CURRENT_USER, r'Software\Classes\VirtualStore\MACHINE\SOFTWARE\Interface Software\ConnMgr', 0, KEY_READ)
        ConnValue = QueryValueEx(ConnKey, "DB Path")
-----
When I execute the program with the line that access the HKCU key, the program retrieves the key as expected. As shown, it is accessing the key explicitly from the virtual store. This shows the key is where I expect it and I can access it.

To test the access of the key in HKLM, I manually created the appropriate key value in HKLM. This is where the application stored the key on Windows XP. I also ran this program both as an administrator and standard user. With KEY_READ access, I can read the key. With KEY_ALL_ACCESS I get the error: [Error 5] Access is denied.

How do I code this so that the access is directed to the Virtual Store, or am I not understanding how this is suppose to work (very possible). I am certain that I'm not the first to encounter this behavior.

Thanks for your help,
John

On 06/03/2013 9:51 PM, John Spitzer wrote:

Hello,

I've searched the python sites and help, library's and all the forums I could find, but haven't seen any mention of this. This help line seemed like a good place to ask this.

I am on an HP laptop Intel Core 2 Duo, running Windows 7 Pro SP1 32Bit. I am using Python 2.7.3.

I have an application I built that ran fine on Windows XP, but now fails on Windows 7. The place I'm encountering the problem is where I try to read a key from the registry. I believe it's because of the Virtualization of the registry on Windows 7. This key is created by another app that I'm trying to co-ordinate with. On Windows XP the Registry key was:

[HKEY_LOCAL_MACHINE\SOFTWARE\Interface Software\ConnMgr]
"DB Path"="C:\\Documents and Settings\\All Users\\Application Data\\<path to a data file>"

When this app is installed on Windows 7, the key is directed to the registry Virtual Store at: [HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Interface Software\ConnMgr]
"DB Path"="C:\\ProgramData\\EnvisionWare\\<path to a data file>"

So far that is what I think I'd expected on Windows 7 and the virtualization of the registry.

The code fragment that is reading the registry is:
-----
from _winreg import *


ConnKey = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Interface Software\ConnMgr', 0, KEY_READ)
        ConnValue = QueryValueEx(ConnKey, "DB Path")
        EWDataSource = os.path.split(str(ConnValue[0]))
------
The OpenKey fails with the message: WindowsError: (2, 'The system cannot find the file specified"). I believe this is because the key does not exist at the path [HKEY_LOCAL_MACHINE\SOFTWARE\Interface Software\ConnMgr].

After all this, the question is: Why isn't the OpenKey call being redirected to the VirtualStore? What can I change in the program, ACLs or other to make it be redirected?

Any help would be appreciated.
Thanks,
John


--
John Spitzer
johned9...@comcast.net
503-590-7434

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to