V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
explist
V2EX  ›  Python

注册表操作疑问

  •  
  •   explist · Feb 15, 2017 · 2666 views
    This topic created in 3357 days ago, the information mentioned may be changed or developed.

    以下代码为何老是出现: PermissionError: [WinError 5] 拒绝访问 异常?

    import winreg as reg

    def proReg():

    subkey = '*\shell'
    key = reg.OpenKey(reg.HKEY_CLASSES_ROOT,subkey)
    with key:
        reg.SetValue(key,'runas',reg.REG_SZ,'TEST')   # 这里抛出异常
        with reg.OpenKey(key,'runas',0,reg.KEY_WRITE) as nkey:
            reg.SetValueEx(nkey,'NoWorkingDirectory',0,reg.REG_SZ,'')
    

    if name == 'main':

       proReg()
    
    2 replies    2017-02-15 15:13:08 +08:00
    progmboy
        1
    progmboy  
       Feb 15, 2017 via iPhone   ❤️ 2
    这个键是高权限的呀,已管理员运行就行了
    explist
        2
    explist  
    OP
       Feb 15, 2017
    行家一出手,.... 谢谢
    @progmboy
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1056 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:18 · PVG 07:18 · LAX 16:18 · JFK 19:18
    ♥ Do have faith in what you're doing.