2

I am trying to use the winreg library of python to access the registry keys for Adobe products (Photoshop, After Effects, Ect.), and while i can see the HKEY_LOCAL_MACHINE subkeys in the Registry Editor, Python can't seem to see the same keys. Is there a permission that needs to be changed or am I approaching this the wrong way?

Here is a Screen cap summarizing the results so far

The code I'm running to see this is:

import winreg
i=0
while True:
    try:
        # self.aeKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Adobe\\After Effects\\16.0")
        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Adobe\Setup\Reader")

        printTest = winreg.EnumKey(key, i)
        print(printTest)
        i+=1
    except WindowsError:
        break

Which results in me having the return of

Acrobat Distiller
Acrobat PDFMaker
Adobe AIR
Adobe ARM
CommonFiles
ExtendScript Toolkit
ExtensionManager
PDF Admin Settings
Registration
Repair
Setup

But not

Adobe Bridge, Adobe Acrobat, After Effects, Photoshop, etc.

Edit: I'm Running 32-Bit Python currently.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • Are you running 32- or 64-bit Python? Windows does some trickery when a 32-bit program tries to access certain things in the registry — something to with WOW (Windows on Windows). There are ways around it… – martineau Apr 15 '20 at 18:51
  • I am running 32 Bit Python, would love to know any ways around the 32/64 bit python wall, Specifically: Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32 – ApollosAnimation Apr 15 '20 at 19:55
  • I forgot to mention that it happens when running 32-bit Python on 64-bit Windows and is called "registry redirection". I'm certainly no expert on the topic — see the questions [Disable registry redirection to Wow6432Node in Python](https://stackoverflow.com/questions/28280377/disable-registry-redirection-to-wow6432node-in-python). and [Opens same registry twice?](https://stackoverflow.com/questions/38703394/opens-same-registry-twice) for more info. – martineau Apr 15 '20 at 20:09
  • 1
    Thanks! will start looking into that direction! – ApollosAnimation Apr 15 '20 at 20:32

1 Answers1

2

@martineau from the comments hit it right on the head! I needed to change the Access key in order to allow 64 bit registries to be found.

import winreg
i=0
while True:
    try:
        # self.aeKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Adobe\\After Effects\\16.0")
        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Adobe",0, winreg.KEY_READ | winreg.KEY_WOW64_64KEY)
        assert key != None, "Key = None"
        printTest = winreg.EnumKey(key, i)
        print(printTest)
        i+=1
    except WindowsError:
        break

Now produces

Acrobat Distiller
Acrobat PDFMaker
Adobe Acrobat
Adobe Bridge
After Effects
Animate
Character Animator
CommonFiles
Dreamweaver 2020
Dreamweaver CC 2019
Identity
Licensing
Photoshop
Prelude
Premiere Pro

Thanks for all the help!

  • Glad to hear you solved the problem and that my suggestions for more research were helpful — as well as for posting your solution for others. – martineau Apr 16 '20 at 00:51
  • Hi ApollosG, could you explain if the registry solution you found helped you getting any closer in using After Effects scripting in Python? Or was it for another purpose? Thank you! – kanjas Sep 29 '22 at 07:23