Search code examples
windowsbatch-filecmdregistryhidden-files

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


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?


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 .