Updating the windows registry with python (Modify path variable in windows with python)
Channel: Canadian Coding
Date: 2020-09-17

I will show you how to update the registry using python. In this example I will be looking at modifying the windows system PATH variable using python. (Click Show More)

Links Referenced
----------------------------
Practical Windows Registry Explanation: https://www.youtube.com/watch?v=tBwAHqqPoQY&feature=youtu.be
ConnectRegistry(): https://docs.python.org/3/library/winreg.html#winreg.ConnectRegistry
HKEY_* Constants: https://docs.python.org/3/library/winreg.html#hkey-constants
OpenKey(): https://docs.python.org/3/library/winreg.html#winreg.OpenKey
Access Rights: https://docs.python.org/3/library/winreg.html#access-rights
EnumValue(): https://docs.python.org/3/library/winreg.html#winreg.EnumValue
SetValueEx(): https://docs.python.org/3/library/winreg.html#winreg.SetValueEx
Value Types: https://docs.python.org/3/library/winreg.html#value-types
Code Used in this video: https://github.com/canadian-coding/video-resources/tree/master/2020/September/16th%20-%20Modification%20of%20Windows%20Registry%20with%20Python

A better version of the completed function is available here: https://github.com/Descent098/pystall/blob/799ec3927da74fde192bac0da208f7acc4274e51/pystall/core.py#L121-L166

===== Social Media/Contact =====
https://canadiancoding.ca/
https://instagram.com/canadiancoding/
https://github.com/canadian-coding
kieran@canadiancoding.ca

Table of Contents
----------------------------
0:00 Intro
0:20 Learn about the registry (See description for link)
0:26 Problem explanation
0:54 What are Hkeys
1:03 Step 1. Connect to the registry with winreg.ConnectRegistry()
2:02 Step 2. Connect to the sub-key with winreg.OpenKey()
3:38 Step 3. Get a value in the sub-key with winreg.EnumValuie()
5:10 Step 4. Modify our data however we want
5:51 Step 5. Update registry with new data using SetValueEx()
7:06 Step 6. Tell the registry to save the changes with ctypes
7:50 Testing the code
8:25 More about winreg
9:03 Shilling (plz subscribe)