V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
chenstack
V2EX  ›  Python

分享一个隐藏 win10 资源管理器中图片等 6 个文件夹和 3D 对象文件夹的脚本

  •  
  •   chenstack · 2018-05-02 13:04:51 +08:00 · 7646 次点击
    这是一个创建于 2398 天前的主题,其中的信息可能已经有所发展或是发生改变。

    更新 win10 的四月更新后,视频、图片、文档、下载、音乐、桌面、3D 对象七个文件夹又拱了出来,选取文件时有点影响,于是翻出之前写的一个隐藏这些文件夹的 python 脚本,想着也许有人需要,于是分享出来。没什么技术含量,代替人工操作注册表而已,python3 的。觉得有用的可以看心情给个Star

    import winreg
    
    
    Explorer = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer')
    key = winreg.OpenKey(Explorer, r'FolderDescriptions')
    
    names = (
        '{0ddd015d-b06c-45d5-8c4c-f59713854639}', # 图片
        '{35286a68-3c57-41a1-bbb1-0eae73d76c95}', # 视频
        '{7d83ee9b-2244-4e70-b1f5-5393042af1e4}', # 下载
        '{a0c69a99-21c8-4671-8703-7934162fcf1d}', # 音乐
        '{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}', # 桌面
        '{f42ee2d3-909f-4907-8871-4c22fc0bf756}', # 文档
    )
    
    for name in names:
        child = winreg.OpenKey(key, name + r'\PropertyBag', 0, winreg.KEY_ALL_ACCESS)
        winreg.SetValueEx(child, "ThisPCPolicy", 0, 1, "Hide")
    
    # 3D 对象
    NameSpace = winreg.OpenKey(Explorer, r'MyComputer\NameSpace')
    winreg.DeleteKey(NameSpace, '{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}')
    
    第 1 条附言  ·  2018-05-02 15:42:49 +08:00
    12 条回复    2018-05-05 13:24:38 +08:00
    devtiange
        1
    devtiange  
       2018-05-02 13:11:59 +08:00
    感谢分享! 不过这种事情, 用 powershell 会更好一点吧.
    yulitian888
        2
    yulitian888  
       2018-05-02 13:16:16 +08:00
    写一个注册表文件不是更简单?

    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag]
    "ThisPCPolicy"="Hide"

    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag]
    "ThisPCPolicy"="Hide"
    jy02534655
        3
    jy02534655  
       2018-05-02 13:47:05 +08:00   ❤️ 3
    ThisPCTweaker 了解下
    yjd
        4
    yjd  
       2018-05-02 13:52:53 +08:00   ❤️ 1
    普通用户还得有 py 环境。俺存的
    ---------------------------------------
    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag]
    "ThisPCPolicy"="Hide"

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag]
    "ThisPCPolicy"="Hide"
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag]
    "ThisPCPolicy"="Hide"

    -----------------------------恢复
    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag]
    "ThisPCPolicy"=-

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag]
    "ThisPCPolicy"=-
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag]
    "ThisPCPolicy"=-
    neighbads
        5
    neighbads  
       2018-05-02 15:44:20 +08:00
    不错哦。。。不知道有没有权限问题。
    chenstack
        6
    chenstack  
    OP
       2018-05-02 15:48:46 +08:00
    @neighbads cmd 或 powershell 要以管理员身份运行
    YTS
        7
    YTS  
       2018-05-02 18:35:30 +08:00 via iPhone
    有个问题,怎么找回来呢😂3D 对象
    kamen
        8
    kamen  
       2018-05-02 18:45:31 +08:00   ❤️ 1
    DISM++了解一下
    kamen
        9
    kamen  
       2018-05-02 18:47:11 +08:00
    @kamen #8 如果你发现了新的自定义 windows 的规则,建议提交给 dism++团队,他们的轮子造的非常好,也有非常多的人在用
    KeySouundsFan
        10
    KeySouundsFan  
       2018-05-02 18:51:36 +08:00
    又不是直接影响生产力,还是尝试养成新的习惯吧,再过个三五年 win10 全面普及,到别人机器上操作的时候你就尝到苦头了
    lqzhgood
        11
    lqzhgood  
       2018-05-04 18:21:02 +08:00
    @yjd 用 “ HIDE ” 有个副作用, [个人文件夹] 里面的 文档神马的也会被隐藏。。。但是从 C:\Users\xx 里面进去还会看得到
    scruel
        12
    scruel  
       2018-05-05 13:24:38 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1274 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:52 · PVG 07:52 · LAX 15:52 · JFK 18:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.