Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python script to import registry key

I have a registry key that contains information for a program that I am running. I have registry key exported to a directory and I can easily import using the regedit Import function. I am having trouble writing a script that does the same using python..

I can read existing keys using the following:

    import _winreg as wreg
    test = wreg.OpenKey(wreg.HKEY_CURRENT_USER, r'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer', 0, wreg.KEY_READ)
    print test

But where I'm having trouble is Importing the key from the directory on my desktop.

like image 915
user28849 Avatar asked Nov 25 '25 01:11

user28849


1 Answers

Xmcp's comment was actually the answer:

import subprocess
subprocess.call(['reg', 'import', filename])
like image 105
Lukas Kalinski Avatar answered Nov 27 '25 15:11

Lukas Kalinski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!