- script for hide/unhide?
- Posted by johnnyzero on January 12th, 2006
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
- Posted by Mungo Bulge on January 12th, 2006
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.
"johnnyzero" <johnbeekman@yahoo.com> wrote in message
news:1137090350.625248.21040@g43g2000cwa.googlegro ups.com...
|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
|
- Posted by johnnyzero on January 12th, 2006
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\Ex plorer\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
************************************************** ******************************
- Posted by Andrew E. on January 13th, 2006
If you want script info go
to:http://www.microsoft.com/technet/scriptcenter.asp
"johnnyzero" wrote:
> 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
>
>
- Posted by johnnyzero on January 13th, 2006
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.
>>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)?
JohnB
************************************************** ******************
p =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Ex plorer\Advanced\ShowSuperHidden"
itemtype = "REG_DWORD"
n = WSHShell.RegRead (p)
errnum = Err.Number
if errnum <> 1 then
WSHShell.RegWrite p, 0, itemtype
************************************************** ***************
- Posted by Admiral Q on January 14th, 2006
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.
--
Star Fleet Admiral Q @ your service!
Google is your friend!
http://www.google.com
"johnnyzero" <johnbeekman@yahoo.com> wrote in message
news:1137166949.237806.196150@z14g2000cwz.googlegr oups.com...
> 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.
>
>>>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)?
>
> JohnB
>
> ************************************************** ******************
> p =
> "HKCU\Software\Microsoft\Windows\CurrentVersion\Ex plorer\Advanced\ShowSuperHidden"
>
> itemtype = "REG_DWORD"
>
> n = WSHShell.RegRead (p)
> errnum = Err.Number
>
> if errnum <> 1 then
>
> WSHShell.RegWrite p, 0, itemtype
> ************************************************** ***************
>