windows - 通过命令提示符更改 "Show hidden files and folders"设置

标签 windows batch-file command-line cmd

有没有办法通过命令提示符更改系统设置(如在我的示例中,显示/隐藏隐藏的文件夹和文件)?如果是这样,这是如何完成的?

最佳答案

要启用您提到的选项,您可以使用REG ADD:

reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 0x1 /f

Windows 资源管理器选项中的“显示隐藏的文件、文件夹和驱动器”等设置最常存储在注册表中。例如,这个看起来像这样:

User Key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
Value Name: Hidden
Data Type: REG_DWORD (DWORD Value)
Value Data: (1 = show hidden, 2 = do not show)

您可以使用reg 命令通过命令行修改 key 。在此处查看更多信息:https://ss64.com/nt/reg.html


要查看“显示隐藏文件”设置是否启用,您可以使用reg query:

reg query HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden

关于 reg add 的更多信息:

REG ADD KeyName [/v ValueName | /ve] [/t type] [/s Separator] [/d Data] [/f]

KeyName     [\\Machine\]FullKey

Machine     Name of remote machine - omitting defaults to the current machine 
            Only HKLM and HKU are available on remote machines
FullKey     ROOTKEY\SubKey ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey 
            The full name of a registry key under the selected ROOTKEY
/v          The value name, under the selected Key, to add
/ve         adds an empty value name <no name> for the key
/t          RegKey data types
            [ REG_SZ | REG_MULTI_SZ | REG_DWORD_BIG_ENDIAN | REG_DWORD | 
              REG_BINARY | REG_DWORD_LITTLE_ENDIAN | REG_NONE | REG_EXPAND_SZ ]
            If omitted, REG_SZ is assumed
/s          Specify one character that you use as the separator in your data 
            string for REG_MULTI_SZ. If omitted, use "\0" as the separator
/d          The data to assign to the registry ValueName being added
/f          Force overwriting the existing registry entry without prompt

关于windows - 通过命令提示符更改 "Show hidden files and folders"设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45014971/

相关文章:

windows - 升级 Windows 的 DOS 批处理文件

xml - 使用 Saxon 9.6HE 自动执行多个文件的 xquery

linux - 最好通过命令行将 Ubuntu 11.04 更新到 12.04

windows - 信息正在等待与 npm 的连接...为 MoodleMobile_2 设置开发环境时出错

python - 将 iOS 应用程序连接到 Windows/Linux 应用程序

windows - 在批处理文件 (7-zip) 中捕获错误

regex - 在Linux上重命名多个文件

c++ - Windows proc/callback 函数可以是类的成员函数吗?

node.js - 创建 Node js Express 应用程序项目时出现错误

batch-file - 用空格替换文件夹名称中的点的批处理脚本