views:

308

answers:

1

I am trying to execute this script by Ned Batchelder to switch .py file association between my two Python installations on Windows. This Python script uses the _winreg module (winreg in Python 3.x) to edit certain Registry values (the path and value pairs modified can be seen in the todo list in the script).

I execute this script as follows:

> SwitchPy.py "C:\Program Files\Python26"

I am getting the following error:

Traceback (most recent call last):
  File "C:\Users\SuperUser\SwitchPy.py", line 30, in <module>
    key = reg.OpenKey(classes_root, path, 0, reg.KEY_SET_VALUE)
WindowsError: [Error 5] Access is denied

I guessed that it could be something to do with account permissions. But, note that:

  • The account used above is part of the Administrators group and has admin privileges.

  • With the above account I can execute regedit.exe and manually set the values listed in the script without facing any permissions or access problems.

I am using Windows 7 and am part of a domain. Could any of this have something to do with this problem?

Does anyone have any clue about this error? How do I make this script run?

A: 

When I tried that one, I got "Path not found" error on Python.CompiledFile.

I checked it on my registry, it does not exist, not Windows 7 though.

So, I removed those lines of Python.CompiledFile and its running fine here, or

You could put try: except: On OpenKey and SetValue, not good idea though.

S.Mark
Actually, yes even my Registry does not have the first 2 entries in the todo list. I removed them and ran the script and faced the above "Access is denied" error.
Ashwin