Created
October 11, 2016 15:45
-
-
Save kendallroth/d80e68e78398cbc15a5f47c13352dc35 to your computer and use it in GitHub Desktop.
Add "Toggle Hidden Files" to Windows context menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
option explicit | |
On Error GoTo 0 | |
'Dim sResult: sResult = Wscript.ScriptName ''' debugging | |
Const HKEY_CURRENT_USER = &H80000001 | |
Dim strComputer, strKeyPath, strValName, dwValue, arrValues, objReg, WshShell | |
arrValues = Array (" unknown", " show hidden files", " hide hidden files" ) | |
strComputer = "." | |
Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") | |
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" | |
strValName = "hidden" | |
objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValName, dwValue | |
If Not (dwValue = 1 OR dwValue = 2) Then dwValue = 0 | |
'sResult = sResult & vbNewLine & CStr( dwValue) & arrValues( dwValue) ''' debugging | |
dwValue = (dwValue Mod 2) + 1 ' switch value 1 <--> 2 | |
'sResult = sResult & " -> " & CStr( dwValue) & arrValues( dwValue) ''' debugging | |
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValName, dwValue | |
set WshShell = WScript.CreateObject("WScript.Shell") | |
WScript.Sleep 30 | |
WshShell.SendKeys "{F5}" ' refresh | |
'Wscript.Echo sResult ''' debugging | |
Wscript.Quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment