script for hide/unhide?

  • Thread starter Thread starter johnnyzero
  • Start date Start date
J

johnnyzero

I was wondering if anyone had a script that'll let me toggle XP's "Hide
Protected Operating System Files & Folders" setting on/off.

I found similar scripts for toggling "Show Hidden Files" and "Hide
Extensions" on Kelly's Korner (excellent site!), but none for *this*
setting...

http://www.kellys-korner-xp.com/xp_tweaks.htm

I often need to change this setting, and one of Kelly's nice scripts
would sure make it a lot easier (hint...hint...) :-)

best,
JohnB
 
Well John, if you have Kelly's Show/Hide files and folders, modify it
to perform the same function for system files and folders. The key is
ShowSupperHidden, the value is 0 for hidden, 1 for show.

|I was wondering if anyone had a script that'll let me toggle XP's
"Hide
| Protected Operating System Files & Folders" setting on/off.
|
| I found similar scripts for toggling "Show Hidden Files" and "Hide
| Extensions" on Kelly's Korner (excellent site!), but none for *this*
| setting...
|
| http://www.kellys-korner-xp.com/xp_tweaks.htm
|
| I often need to change this setting, and one of Kelly's nice scripts
| would sure make it a lot easier (hint...hint...) :-)
|
| best,
| JohnB
|
 
Mungo,

Thanks for your reply - I hope you didn't think I was being lazy or
something. I'm not a VBS/programmer guy at all; but like a lotta people
I can usually manage to modify someone's existing script for my
purposes without mucking things up too badly.

I had actually started to mod Kelly's "Show Hidden Folders" script, but
wasn't sure about one section of his code. Besides the key name and
some message boxes, the only real change needed was to change the
possible key values to 0 or 1, instead of 1 or 2.

It works fine except for one section I'm not clear on - maybe you or
someone else here can just help me with the "errnum <>1" part. Is the
purpose of this to set the key to a specific value if the key doesn't
already exist (or if some other error is returned)?

my code is below...

thanks,
JohnB


********************************************************************************
Message = "To work correctly, this script will close" & vbCR
Message = Message & "and restart the Windows Explorer shell." & vbCR
Message = Message & "This will not harm your system." & vbCR & vbCR
Message = Message & "Continue?"

X = MsgBox(Message, vbYesNo, "Notice")

If X = 6 Then
On Error Resume Next


On Error Resume Next

Dim WSHShell, n, p, itemtype, MyBox
Set WSHShell = WScript.CreateObject("WScript.Shell")

p =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden"

itemtype = "REG_DWORD"

n = WSHShell.RegRead (p)
errnum = Err.Number

if errnum <> 1 then

WSHShell.RegWrite p, 0, itemtype
End If

If n = 1 Then
WshShell.RegWrite p, 0, itemtype
MyBox = MsgBox("Protected Operating System Files and Folders are now
HIDDEN", 64, "Operating System Files and Folders")
End If

If n = 0 Then
WshShell.Regwrite p, 1, itemtype
MyBox = MsgBox("Protected Operating System Files and Folders are now
VISIBLE", 64, "Operating System Files and Folders")
End If

Set WshShell = Nothing

On Error GoTo 0

For Each Process in GetObject("winmgmts:"). _
ExecQuery ("select * from Win32_Process where name='explorer.exe'")
Process.terminate(0)
Next

MsgBox "Finished." & vbcr & vbcr , 4096, "Done"

Else

MsgBox "No changes were made to your system." & vbcr & vbcr, 4096,
"User Cancelled"

End If

********************************************************************************
 
Thanks, Andrew.

Actually, I was asking about the purpose of that part of the code *in
the context of this particular script*, not about the "errnum" function
itself.
already exist (or if some other error is returned)?

JohnB

********************************************************************
p =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden"

itemtype = "REG_DWORD"

n = WSHShell.RegRead (p)
errnum = Err.Number

if errnum <> 1 then

WSHShell.RegWrite p, 0, itemtype
*****************************************************************
 
Try asking for script debugging in the correct forum -
microsoft.public.scripting.vbscript would be a good place to start, and the
experts there may have additional suggestions.
 
Back
Top