China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 23:50
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Resolved Issue] Batch script to remove the hidden attribute of hidden folders (注:原内容中“[已解决的问题]”翻译为“[Resolved Issue]”,“去掉隐藏文件夹隐藏属性的批处理”翻译为“Batch script to remove the hidden attribute of hidden folders”,整体按照要求准确翻译,保留了原有的格式和内容。) View 3,629 Replies 11
Original Poster Posted 2008-05-15 17:33 ·  中国 云南 昆明 电信
初级用户
Credits 64
Posts 27
Joined 2007-03-08 21:35
19-year member
UID 81100
Gender Male
Status Offline
Seek batch scripts to display hidden folders

Recently, the USB flash drive has been frequently infected by viruses, causing all the folders inside to be hidden.

How to use a batch script to remove the hidden attributes of these folders..

By the way, give some explanations. I have learned a little about batch processing, but I'm very novice..

[ Last edited by Auto on 2008-5-17 at 09:46 AM ]
Floor 2 Posted 2008-05-15 19:21 ·  中国 上海 鹏博士宽带
中级用户
★★
Credits 484
Posts 250
Joined 2007-06-05 23:33
19-year member
UID 90372
Gender Male
Status Offline
dir /a
attrib -s -h -r
Floor 3 Posted 2008-05-15 19:27 ·  中国 云南 昆明 电信
初级用户
Credits 64
Posts 27
Joined 2007-03-08 21:35
19-year member
UID 81100
Gender Male
Status Offline
Originally posted by pooronce at 2008-5-15 07:21 PM:
dir /a
attrib -s -h -r

I know this is relatively troublesome. I want a batch processing with high automation level that can display all hidden folders in the current directory as soon as it runs
Floor 4 Posted 2008-05-15 19:35 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
It's not that the folder is hidden, but that the registry has been modified.

Save the following code as ShowAll.reg, and double-click to import the registry to view hidden files.

Windows Registry Editor Version 5.00


"RegPath"="Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"
"Text"="@shell32.dll,-30501"
"Type"="radio"
"CheckedValue"=dword:00000002
"ValueName"="Hidden"
"DefaultValue"=dword:00000002
"HKeyRoot"=dword:80000001
"HelpID"="shell.hlp#51104"

"RegPath"="Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"
"Text"="@shell32.dll,-30500"
"Type"="radio"
"CheckedValue"=dword:00000001
"ValueName"="Hidden"
"DefaultValue"=dword:00000002
"HKeyRoot"=dword:80000001
"HelpID"="shell.hlp#51105"

"Type"="checkbox"
"Text"="@shell32.dll,-30508"
"WarningIfNotDefault"="@shell32.dll,-28964"
"HKeyRoot"=dword:80000001
"RegPath"="Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"
"ValueName"="ShowSuperHidden"
"CheckedValue"=dword:00000000
"UncheckedValue"=dword:00000001
"DefaultValue"=dword:00000000
"HelpID"="shell.hlp#51103"

Floor 5 Posted 2008-05-16 15:10 ·  中国 云南 昆明 电信
初级用户
Credits 64
Posts 27
Joined 2007-03-08 21:35
19-year member
UID 81100
Gender Male
Status Offline
I want to remove the hidden attributes of these folders..
Continue to ask for help
Still thank you to the above
Floor 6 Posted 2008-05-16 15:16 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Originally posted by Auto at 2008-5-16 03:10 PM:
I want to remove the hidden attributes of these folders..
Continue to ask for help
Still thank you upstairs

@echo off
set SrcDir=C:\test
for /f "tokens=1* delims=" %%a in ('dir /s /b /ad "%SrcDir%"') do (
attrib -h -s -a -r "%SrcDir%\%%a"
)
Floor 7 Posted 2008-05-16 22:53 ·  中国 北京 联通
银牌会员
★★★
Credits 1,287
Posts 634
Joined 2007-05-02 15:06
19-year member
UID 87277
Gender Male
From cmd.exe
Status Offline
dir /AHD /s /b
Then refer to LS's code and add FOR
Floor 8 Posted 2008-05-17 09:27 ·  中国 云南 昆明 电信
初级用户
Credits 64
Posts 27
Joined 2007-03-08 21:35
19-year member
UID 81100
Gender Male
Status Offline
@echo off
set SrcDir=D:\Tools\test
for /f "tokens=1* delims=" %%a in ('dir /AHD /s /b "%SrcDir%"') do (
attrib -h -s -a -r "%SrcDir%\%%a"
)
pause

I ran the above and got the following prompt
The system cannot find the path - D:\Tools\test\D:\Tools\test
The system cannot find the path - D:\Tools\test\D:\Tools\test
The system cannot find the path - D:\Tools\test\D:\Tools\test
The system cannot find the path - D:\Tools\test\D:\Tools\test
Press any key to continue . . .

After摸索, I just found out..
The /s parameter in the dir sentence should be removed..


Also, I need someone to improve it
That is, put this batch file in that folder and run it to remove the hidden attribute of the hidden folders in the current folder
That is, how to replace the value of the variable SrcDir with the current path..

[ Last edited by Auto on 2008-5-17 at 09:29 AM ]
Floor 9 Posted 2008-05-17 09:44 ·  中国 云南 昆明 电信
初级用户
Credits 64
Posts 27
Joined 2007-03-08 21:35
19-year member
UID 81100
Gender Male
Status Offline
Through the guidance of the above - mentioned各位 and my own exploration, the batch processing I need should be like this:

:: Remove the hidden attribute of sub - folders in the current folder
@echo off
for /f "tokens=1* delims=" %%a in ('dir /adh /b') do (
attrib -h -s -a -r ".\%%a"
)


Thank you, above - mentioned各位 brothers.

[ Last edited by Auto on 2008 - 5 - 17 at 09:46 AM ]
Floor 10 Posted 2009-12-16 00:26 ·  中国 江西 上饶 电信
初级用户
Credits 31
Posts 24
Joined 2009-04-04 10:37
17-year member
UID 142105
Gender Male
Status Offline
Floor 11 Posted 2009-12-16 01:44 ·  中国 天津 电信
初级用户
★★
Credits 128
Posts 122
Joined 2009-09-21 06:24
16-year member
UID 152378
Gender Male
Status Offline
First, use the one from floor 4, modify the registry to show all hidden files and system files, then directly drag the hidden file onto this batch processing:
attrib -s -h %1
Simple and clear
Floor 12 Posted 2009-12-16 21:19 ·  中国 江西 上饶 广信区 电信
初级用户
Credits 31
Posts 24
Joined 2009-04-04 10:37
17-year member
UID 142105
Gender Male
Status Offline
Good post. Very helpful to myself
Forum Jump: