Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

show/hide hidden files quickly

Posted on 2000-03-01
13
Medium Priority
?
319 Views
Last Modified: 2013-12-28
The fastest way that I have figured out to show/hide hidden and system files is to open my computer, go to View, choose Folder options, go to view and click the radial.  I was hoping that there might be some way to create a short cut either right to the last screen or that just changed the setting from show to hide automatically and so that I could put the shortcut on the start menu or desktop.  Does anyone know of a way?  If the solution requires coding, could you provide it?  I don't remember much.  Thanks.
0
Comment
Question by:griffen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +3
13 Comments
 
LVL 6

Expert Comment

by:1cell
ID: 2573810
unfortunately, that's it!
0
 
LVL 1

Expert Comment

by:Fei
ID: 2573813
You can make a batch file such as hide.bat and put it on your desktop.  Place the command "attrib +h *" inside the file to hide all files within the directory. Here is the options for the command attrib.  

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [[drive:] [path] filename] [/S]

  +   Sets an attribute.
  -   Clears an attribute.
  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  /S  Processes matching files in the current directory and all subdirectories.

0
 
LVL 1

Expert Comment

by:Fei
ID: 2573829
To unhide the files type make an another batch file and put the command "attrib -h *"
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:1cell
ID: 2573844
oh yeah, a batch file!  duh, sorry!
0
 

Expert Comment

by:mcclim
ID: 2573873
Why not write a VB program that would do it easier for you... and with a nicer interface.

Neil
0
 

Author Comment

by:griffen
ID: 2573940
Well, how do I write the VB file?  Or if I use the batch file, I have certain folders that I want to hide/unhide and others that I have system files in that I would like to hide/unhide.  If I put the .bat on the desktop, how will it know which folder I want to hide, and if I put it in the folder, then how do I get to it when it is hidden?
0
 

Expert Comment

by:tremblyj
ID: 2574573
Guys, guys !!!!
You are getting confused.  Re-read griffen's question.  He wants to enable/disable the DISPLAYING of hidden and system files.  He doesn't want to actually hide and unhide hidden and system files.  Right griffen ?

1cell is right.  If the option for this is stored in the registry, good look in creating a quick util to toggle it on and off.  Maybe if the option was stored in an .INI file, you could right a quick and dirty routine to modify the value.
0
 
LVL 2

Expert Comment

by:ggilman
ID: 2574613
Here's some VB code that will toggle between show all and show neither hidden or system.

part 1: This is a sample form I have. I click a command button which causes the toggle
Const HKEY_CURRENT_USER = &H80000001
Const HIDDEN_SETTINGS_KEY = "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
Enum hiddenValue
    hideAll = 0     'Both hidden and system files are not shown
    showAll = 1     'Show both hidden and system files
    HideHidden = 2  'Hide hidden files but show system files
End Enum
Private Sub Command1_Click()
    Dim retVal As Long
    Dim dataType As Long
   
    retVal = Val(GetKeyValue(HKEY_CURRENT_USER, HIDDEN_SETTINGS_KEY, "Hidden"))
   
    Select Case Val(retVal)
    Case hideAll
        Call UpdateKey(HKEY_CURRENT_USER, HIDDEN_SETTINGS_KEY, "Hidden", showAll)
    Case showAll
        Call UpdateKey(HKEY_CURRENT_USER, HIDDEN_SETTINGS_KEY, "Hidden", hideAll)
    Case HideHidden
        'Leave the same??
    End Select
End Sub

Part 2: This is a module

' This module reads and writes registry keys.  Unlike the
' internal registry access methods of VB, it can read and
' write any registry keys with string values.

Option Explicit
'---------------------------------------------------------------
'-Registry API Declarations...
'---------------------------------------------------------------
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, ByRef phkResult As Long, ByRef lpdwDisposition As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As Long, ByVal cbData As Long) As Long

'---------------------------------------------------------------
'- Registry Api Constants...
'---------------------------------------------------------------
' Reg Data Types...
Const REG_SZ = 1                         ' Unicode nul terminated string
Const REG_EXPAND_SZ = 2                  ' Unicode nul terminated string
Const REG_DWORD = 4                      ' 32-bit number

' Reg Create Type Values...
Const REG_OPTION_NON_VOLATILE = 0       ' Key is preserved when system is rebooted

' Reg Key Security Options...
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_READ = KEY_QUERY_VALUE + KEY_ENUMERATE_SUB_KEYS + KEY_NOTIFY + READ_CONTROL
Const KEY_WRITE = KEY_SET_VALUE + KEY_CREATE_SUB_KEY + READ_CONTROL
Const KEY_EXECUTE = KEY_READ
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
                       KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
                       KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
                     
' Reg Key ROOT Types...
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_PERFORMANCE_DATA = &H80000004

' Return Value...
Const ERROR_NONE = 0
Const ERROR_BADKEY = 2
Const ERROR_ACCESS_DENIED = 8
Const ERROR_SUCCESS = 0

'---------------------------------------------------------------
'- Registry Security Attributes TYPE...
'---------------------------------------------------------------
Private Type SECURITY_ATTRIBUTES
    nLength As Long
    lpSecurityDescriptor As Long
    bInheritHandle As Boolean
End Type

' The resource string will be loaded into a control's property as follows:
' Object      Property
' Form        Caption
' Menu        Caption
' TabStrip    Caption, ToolTipText
' Toolbar     ToolTipText
' ListView    ColumnHeader.Text

Sub LoadResStrings(frm As Form)
  On Error Resume Next
 
  Dim ctl As Control
  Dim obj As Object
 
  'set the form's caption
  If IsNumeric(frm.Tag) Then
    frm.Caption = LoadResString(CInt(frm.Tag))
  End If
 
  'set the controls' captions using the caption
  'property for menu items and the Tag property
  'for all other controls
  For Each ctl In frm.Controls
    Err.Clear
    If TypeName(ctl) = "Menu" Then
      If IsNumeric(ctl.Caption) Then
        If Err = 0 Then
          ctl.Caption = LoadResString(CInt(ctl.Caption))
        End If
      End If
    ElseIf TypeName(ctl) = "TabStrip" Then
      For Each obj In ctl.Tabs
        Err.Clear
        If IsNumeric(obj.Tag) Then
          obj.Caption = LoadResString(CInt(obj.Tag))
        End If
        'check for a tooltip
        If IsNumeric(obj.ToolTipText) Then
          If Err = 0 Then
            obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
          End If
        End If
      Next
    ElseIf TypeName(ctl) = "Toolbar" Then
      For Each obj In ctl.Buttons
        Err.Clear
        If IsNumeric(obj.Tag) Then
          obj.ToolTipText = LoadResString(CInt(obj.Tag))
        End If
      Next
    ElseIf TypeName(ctl) = "ListView" Then
      For Each obj In ctl.ColumnHeaders
        Err.Clear
        If IsNumeric(obj.Tag) Then
          obj.Text = LoadResString(CInt(obj.Tag))
        End If
      Next
    Else
      If IsNumeric(ctl.Tag) Then
        If Err = 0 Then
          ctl.Caption = LoadResString(CInt(ctl.Tag))
        End If
      End If
      'check for a tooltip
      If IsNumeric(ctl.ToolTipText) Then
        If Err = 0 Then
          ctl.ToolTipText = LoadResString(CInt(ctl.ToolTipText))
        End If
      End If
    End If
  Next

End Sub

'-------------------------------------------------------------------------------------------------
'sample usage - Debug.Print UpodateKey(HKEY_CLASSES_ROOT, "keyname", "newvalue")
'-------------------------------------------------------------------------------------------------
Public Function UpdateKey(KeyRoot As Long, KeyName As String, SubKeyName As String, SubKeyValue As Long) As Boolean
    Dim rc As Long                                      ' Return Code
    Dim hKey As Long                                    ' Handle To A Registry Key
    Dim hDepth As Long                                  '
    Dim lpAttr As SECURITY_ATTRIBUTES                   ' Registry Security Type
   
    lpAttr.nLength = 50                                 ' Set Security Attributes To Defaults...
    lpAttr.lpSecurityDescriptor = 0                     ' ...
    lpAttr.bInheritHandle = True                        ' ...

    '------------------------------------------------------------
    '- Create/Open Registry Key...
    '------------------------------------------------------------
    rc = RegCreateKeyEx(KeyRoot, KeyName, _
                        0, REG_DWORD, _
                        REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, lpAttr, _
                        hKey, hDepth)                   ' Create/Open //KeyRoot//KeyName
   
    If (rc <> ERROR_SUCCESS) Then GoTo CreateKeyError   ' Handle Errors...
   
    '------------------------------------------------------------
    '- Create/Modify Key Value...
    '------------------------------------------------------------
   ' If (SubKeyValue = "") Then SubKeyValue = " "        ' A Space Is Needed For RegSetValueEx() To Work...
   
    ' Create/Modify Key Value
    rc = RegSetValueEx(hKey, SubKeyName, _
                       0, REG_DWORD, _
                       VarPtr(SubKeyValue), Len(SubKeyValue)) 'LenB(StrConv(Str(SubKeyValue), vbFromUnicode)))
                       
    If (rc <> ERROR_SUCCESS) Then GoTo CreateKeyError   ' Handle Error
    '------------------------------------------------------------
    '- Close Registry Key...
    '------------------------------------------------------------
    rc = RegCloseKey(hKey)                              ' Close Key
   
    UpdateKey = True                                    ' Return Success
    Exit Function                                       ' Exit
CreateKeyError:
    UpdateKey = False                                   ' Set Error Return Code
    rc = RegCloseKey(hKey)                              ' Attempt To Close Key
End Function

'-------------------------------------------------------------------------------------------------
'sample usage - Debug.Print GetKeyValue(HKEY_CLASSES_ROOT, "COMCTL.ListviewCtrl.1\CLSID", "")
'-------------------------------------------------------------------------------------------------
Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String) As String
    Dim i As Long                                           ' Loop Counter
    Dim rc As Long                                          ' Return Code
    Dim hKey As Long                                        ' Handle To An Open Registry Key
    Dim hDepth As Long                                      '
    Dim sKeyVal As String
    Dim lKeyValType As Long                                 ' Data Type Of A Registry Key
    Dim tmpVal As String                                    ' Tempory Storage For A Registry Key Value
    Dim KeyValSize As Long                                  ' Size Of Registry Key Variable
   
    ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
    '------------------------------------------------------------
    rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
   
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Error...
   
    tmpVal = String$(1024, 0)                             ' Allocate Variable Space
    KeyValSize = 1024                                       ' Mark Variable Size
   
    '------------------------------------------------------------
    ' Retrieve Registry Key Value...
    '------------------------------------------------------------
    rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
                         lKeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
                       
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Errors
     
    tmpVal = Left$(tmpVal, InStr(tmpVal, Chr(0)) - 1)

    '------------------------------------------------------------
    ' Determine Key Value Type For Conversion...
    '------------------------------------------------------------
    Select Case lKeyValType                                  ' Search Data Types...
    Case REG_SZ, REG_EXPAND_SZ                              ' String Registry Key Data Type
        sKeyVal = tmpVal                                     ' Copy String Value
    Case REG_DWORD                                          ' Double Word Registry Key Data Type
        For i = Len(tmpVal) To 1 Step -1                    ' Convert Each Bit
            sKeyVal = sKeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' Build Value Char. By Char.
        Next
        sKeyVal = Format$("&h" + sKeyVal)                     ' Convert Double Word To String
    End Select
   
    GetKeyValue = sKeyVal                                   ' Return Value
    rc = RegCloseKey(hKey)                                  ' Close Registry Key
 
    Exit Function                                           ' Exit
   
GetKeyError:    ' Cleanup After An Error Has Occured...
    GetKeyValue = vbNullString                              ' Set Return Val To Empty String
    rc = RegCloseKey(hKey)                                  ' Close Registry Key
End Function

0
 
LVL 2

Expert Comment

by:ggilman
ID: 2574625
I've tested my solution and it works fine for a toggle. You should be able to modify the form code pretty easily to suit your needs & provide a nice interface. As tremblyj mentioned, the setting is stored in the registry. Changing the value to 0,1,2 changes the view options.
0
 
LVL 2

Accepted Solution

by:
ggilman earned 1200 total points
ID: 2574628
By the way, some of the comments in the module code don't mean a whole lot. I took the code from the online help and modified it some to suit your purpose.
0
 

Author Comment

by:griffen
ID: 2574776
Wow, thank you very much.  I must admit though that the only VB I have ever done is from within Access, so I am not sure where to do this.  Do I need MS Visual Basic to create this program.  I think I have an old copy of it somewhere.  Can I use the windows scripting host?  Either way, thank you for your help.
0
 
LVL 2

Expert Comment

by:ggilman
ID: 2575201
Your best choice would be to use Visual Basic. What I did was create a new standard exe project. Add a code module. Copy all of the code after "Part 2: This is a module" and paste it into the module. Now the part about how you want the rest of the design is really up to you. What I did to test it out was add a command button on the form. Copy the "Part 1" code into the form. Now when you click the command button, it acts as a toggle. But that's just the way I did it.
     Using the same commands I have programmed for the command button, you can just as easily have an application that uses no form and just does the toggle, which may actually be a little more like you want. To do this, create a second Module. In this module create a subroutine "Sub Main". Put the toggle code there. Under project properties, set the start up object to be "Sub Main". Compile and you're done. Again another variation would be to create your own radio buttons on the form and have them choose the mode rather than a toggle. If you decide which way you want to do it and need some more info, feel free to ask & I'll try to help.

I've never used windows scripting host so I can't exactly answer that question. However, for the most part, it should work anywhere you can program in VB, at least anywhere you can call APIs and have access to the registry. Again, I haven't tried modifying the registry other than through VB itself but other than the API calls it's just basic VB. The biggest thing you need is the HIDDEN_SETTINGS_KEY that I had to search for to get your solution.

--ggilman
0
 
LVL 2

Expert Comment

by:ggilman
ID: 2575206
Of course, if you copy the "Part 1" code, you need "Command1_Click" to be renamed to the name of your command button.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question