Using Python’s winreg, how can I make changes to the Windows Registry that I can confirm worked in Regedit?

My python code is below. Online guides and Stack Overflow posts suggest this should work, but it doesn’t seem to. When I change the registry, it does a new get to confirm the change was made properly and, according to that result, it shows that the value IS changing. Additionally, if I kill the Flask server and restart it, the page shows the change as well

But I can’t confirm the changes in the actual registry. When I check ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager the SubscribedContent-310093Enabled value never changes (yes, I’m pressing f5 to reload… even tried closing and reopening Regedit).

The code thinks it changed something though. If I click the button to toggle the setting, kill the flask server, and re-run, it shows the opposite setting (weirdly I have to reload the actual flask server and can’t just reload the webpage).

What am I doing wrong?

from flask import Flask, render_template, request, jsonify
import winreg

app = Flask(__name__)

fixes = {
    "welcome": {
        "pref_name": "WelcomeExperienceAfterEveryDamnedUpdate",
        "img": "graphics/windows_welcome.png",
        "title": "Disable 'Welcome to Windows' after updates",
        "snark": """
            Another volley in Microsoft's cloying desperation to trick you into picking Edge as your browser; the Welcome to Windows screen that shows up after updates is clearly intended into 
            confusing you into selecting their browser (and other options that benefit Microsoft) instead of leaving your crap alone... the way you already set it.
            """,                
        "description": """
            On major updates to Windows, it shows you the Welcome Experience again in an attempt to give you a second chance to do things their way. If you don't need the nag, 
            click this fix to disable this obnoxious behavior.
            """,
        "tags": ["#Windows", "#Update", "#Nags", "#PweaseUseEdgeSenpaiUwU", "#TrickGrandma"],
        "reg_fix": {
            "key_path": r"SOFTWAREMicrosoftWindowsCurrentVersionContentDeliveryManager", 
            "value_name": "SubscribedContent-310093Enabled",
            "fixed_val": 0, 
            "broke_val": 1,
        }
    },  
}

# -1 means break it
# 0 or None means "get"
# 1 means fix it
# returns 
#   on get: the value
#   on set: "changed", "same", or "error"
def reg_fixer(fixes, which, fix_it=None):
    reg_fix = fixes[which]["reg_fix"]

    try:
        # Open the registry key for reading and writing
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, reg_fix["key_path"], 0, winreg.KEY_READ | winreg.KEY_WRITE)
    except FileNotFoundError:
        # Handle if the key doesn't exist
        key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, reg_fix["key_path"])
    
    # Get the previous value of the registry key
    try:
        current_value, _ = winreg.QueryValueEx(key, reg_fix["value_name"])
        current_value = int(current_value)  # Convert value to integer
    except FileNotFoundError:
        current_value = None  # No previous value if the value doesn't exist

    # GET OPERATION STOPS HERE!!!
    if fix_it is None:
        winreg.CloseKey(key)
        return {"current": current_value, "fixed_val": reg_fix["fixed_val"], "broke_val": reg_fix["broke_val"], "is_fixed": (current_value == reg_fix["fixed_val"])}

    # POST OPERATION (fix_it is not None)
    note = None
    try:
        change_to = reg_fix["fixed_val"] if (fix_it == 1) else reg_fix["broke_val"]
        if change_to == current_value:
            note = "no change"
        else:
            # Set the new value for the registry key
            winreg.SetValueEx(key, reg_fix["value_name"], 0, winreg.REG_DWORD, change_to)
            # Another GET just to be sure the change worked
            current_value, _ = winreg.QueryValueEx(key, reg_fix["value_name"])
            current_value = int(current_value)  # Convert value to integer
            if current_value != change_to:
                note = "change failed!"
    except Exception as e:
        # If the update fails, set the previous and current values to be the same
        print(f"Error setting registry value: {e}")
        note = f"Error setting registry value: {e}"

    winreg.CloseKey(key)
    return {"current": current_value, "fixed_val": reg_fix["fixed_val"], "broke_val": reg_fix["broke_val"], "is_fixed": (current_value == reg_fix["fixed_val"]), "note": note}
        
settings = {}

for key, a_fix in fixes.items():
    settings[a_fix["pref_name"]] = reg_fixer(fixes,key)["is_fixed"]

@app.route('/')
def home_page():
    return render_template("index.html", fixes=fixes, settings=settings)

@app.route('/toggle_fix', methods=['POST'])
def toggle_fix():
    global fixes,settings
    
    data = request.get_json()
    fix_key = data.get('fix_key')
    is_fixed = data.get('fixed')

    # undo the fix if it IS fixed otherwise fix it
    result = reg_fixer(fixes,fix_key,-1 if is_fixed else 1)
    
    response = {'status': 'success', 'message': {"text":f'Toggled fix {fix_key}', 'fixed': result["is_fixed"], 'fun_return': result }}
    return jsonify(response)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật