简体   繁体   English

PermissionError:[WinError 5] 访问被拒绝(Windows Update Disabler)

[英]PermissionError: [WinError 5] Access is denied (Windows Update Disabler)

Im having trouble with my windows update disabler script, whenever i run in in an unelevated shell i get an error PermissionError: [WinError 5] Access is denied but whenever i run with and elevated shell it just closes with no error. Im having trouble with my windows update disabler script, whenever i run in in an unelevated shell i get an error PermissionError: [WinError 5] Access is denied but whenever i run with and elevated shell it just closes with no error. What can i do to avoid, or get rid of this error.我能做些什么来避免或摆脱这个错误。

import winreg
option = input("Would you like to continue: ")
if option == ('yes'):
    medic = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, 'SYSTEM\\CurrentControlSet\\Services\\WaaSMedicSvc')
    winreg.SetValueEx(medic, 'Start', 0, winreg.REG_SZ, '4')
    medic.Close()
    wua = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, 'SYSTEM\\CurrentControlSet\\Services\\wuauserv')
    winreg.SetValueEx(wua, 'Start', 0, winreg.REG_SZ, '4')
    wua.Close()
if option == ('no'):
    exit()
else:
    print("Input Error")

You run it in an elevated shell.您在提升的 shell 中运行它。 The Services key is protected.服务密钥受到保护。 You know, you can make a.reg file and feed it directly to regedit .您知道,您可以制作一个 .reg 文件并将其直接提供给regedit That will automatically ask for elevation.这将自动要求提升。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM