【问题标题】:Change "Show hidden files and folders" setting via Command Prompt通过命令提示符更改“显示隐藏的文件和文件夹”设置
【发布时间】:2017-07-10 14:39:16
【问题描述】:

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

【问题讨论】:

  • 这不是很清楚你在问什么。您是希望使用命令行使隐藏文件在常规 Windows 资源管理器中可见,还是希望在使用 dir 命令时默认列出隐藏文件?
  • @JeffZeitlin 我正在尝试使用命令行使隐藏文件在使用 GUI 和资源管理器时可见。
  • 您可能会发现stackoverflow.com/questions/4491999/… 很有用。

标签: windows batch-file command-line cmd


【解决方案1】:

要启用您提到的选项,您可以使用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 命令通过命令行修改密钥。在此处查看更多信息: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

【讨论】:

  • 我可以通过这个破解一个解决方案。有没有办法检查当前的属性是什么?所以如果隐藏了,其他的会这样做吗?
  • @Harry:attrib &lt;filename or folder&gt;会显示当前属性,包括隐藏、系统等。
  • @HarryAdams - 虽然在这里可能没用,attrib _file_ 将文件属性报告给标准输出。你可以在ss64.com/nt找到很多关于命令行的信息
  • 我明白了,您说的是 Windows 资源管理器设置“显示隐藏的文件、文件夹和驱动器”。
  • 已编辑以添加更多信息和示例。
猜你喜欢
  • 2015-04-25
  • 1970-01-01
  • 1970-01-01
  • 2020-02-01
  • 2016-01-22
  • 2019-01-14
  • 2019-10-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多