Windows Show / hide hidden files / folder - at single click - is it possible using batch file - or at single click?

StackOverflow https://stackoverflow.com/questions/18502844

Question

To show/hide hidden files/folders in windows OSes like XP, Vista or Seven, we have to...

  1. go to explorer
  2. select tools menu
  3. folder option
  4. view tab
  5. select radio button to show/hide hidden files/filers

Is there any dos command/batch script to do this? I just want to make it done using single click(whether it is .bat file or anything).

I searched and found an answer for the files affected by viruses - Windows batch script to unhide files hidden by virus - but it is specific for a single drive user has entered- and that too, for affected by virus.

I also found the change needed in registry for this.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"Hidden"=dword:00000001
"HideFileExt"=dword:00000000

I am new to registry editing thing. So I don't know how to do this stuff.
So, how can I make it happen - at a single click - I can enable/disable viewing hidden files and folders?

Was it helpful?

Solution

you might try this:

@echo off &setlocal
set "regkey=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
for /f "tokens=2*" %%a in ('reg query %regkey% /v Hidden^|find "REG_DWORD"') do set /a Hidden=%%b
for /f "tokens=2*" %%a in ('reg query %regkey% /v ShowSuperHidden^|find "REG_DWORD"') do set /a SSuperHidden=%%b
if "%hidden%"=="1" (set /a hidden=2, SSuperHidden=0) else set /a hidden=1, SSuperHidden=1
reg add %regkey% /f /v Hidden /t REG_DWORD /d %hidden% >nul
reg add %regkey% /f /v ShowSuperHidden /t REG_DWORD /d %SSuperHidden% >nul
for /f "tokens=2*" %%a in ('reg query %regkey% /v Hidden^|find "REG_DWORD"') do set /a Hidden=%%b
<nul set /p="System files and folder are "
if "%hidden%"=="1" (echo NOT hidden.) else echo hidden.
endlocal
PAUSE 

You must update the explorer by yourself by pressing F5. To do this by script you need .

OTHER TIPS

A possibly more convenient way to accomplish this with minimal effort is through adding a context menu item, to do this:

  1. Create a new simple text document somewhere and name it "togglehidden.reg"
  2. Open it with notepad and paste the following:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Folder\shell\Windows.ShowHiddenFiles]
    "CommandStateSync"=""
    "Description"="@shell32.dll,-37573"
    "ExplorerCommandHandler"="{f7300245-1f4b-41ba-8948-6fd392064494}"
    "MUIVerb"="@shell32.dll,-37572"
    
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\Windows.ShowHiddenFiles]
    "CommandStateSync"=""
    "Description"="@shell32.dll,-37573"
    "ExplorerCommandHandler"="{f7300245-1f4b-41ba-8948-6fd392064494}"
    "MUIVerb"="@shell32.dll,-37572"
    
  3. save and close.

  4. double click your new reg file, accept prompts to install it and you're done.

This is what you should get: Hidden Toggle

Source: https://winaero.com/blog/hidden-items-context-menu-windows-10/

This script worked great for me:

Hidden = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"
SHidden = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden"

Set Sh = WScript.CreateObject("WScript.Shell")
St = Sh.RegRead(Hidden)

If St = 2 Then
    Sh.RegWrite Hidden, 1, "REG_DWORD"
    Sh.RegWrite SHidden, 1, "REG_DWORD"
Else
    Sh.RegWrite Hidden, 2, "REG_DWORD"
    Sh.RegWrite SHidden, 0, "REG_DWORD"
End If

Sh.SendKeys("{F5}")
  1. win + R
  2. write cmd
  3. place on the route
  4. write attrib -h -r -s / s / d d: \ *. *
    and change
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top