Updating the windows registry with python (Modify path variable in windows with python)

Опубликовано: 24 Март 2025
на канале: Canadian Coding
9,999
132

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:    • Practical Windows Registry Explanation  
ConnectRegistry(): https://docs.python.org/3/library/win...
HKEY_* Constants: https://docs.python.org/3/library/win...
OpenKey(): https://docs.python.org/3/library/win...
Access Rights: https://docs.python.org/3/library/win...
EnumValue(): https://docs.python.org/3/library/win...
SetValueEx(): https://docs.python.org/3/library/win...
Value Types: https://docs.python.org/3/library/win...
Code Used in this video: https://github.com/canadian-coding/vi...

A better version of the completed function is available here: https://github.com/Descent098/pystall...

===== Social Media/Contact =====
https://canadiancoding.ca/
  / canadiancoding  
https://github.com/canadian-coding
[email protected]

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)