I noticed the other day that all of my folders seemed to be showing info in details for media files, ie, Artist, Album, Track#, Genre, etc.
This was rather disturbing while viewing my script directory. On folders that i specifically set the info to be size, type, date modified, etc. things worked fine. On most others, it was in "media view" - as if I had right-clicked the folders and selectesd Customize -> Music Details... only I hadn't. So, to fix this across all my drives, without having to manually modify each folder, I came up with this:
'==========================================================================
'
' SCRIPT NAME: ClearAllFoldersColumnSettings.vbs
'
' AUTHOR: DiGiTAL.SkReAM
' DATE : 3/10/2007
'
' COMMENT: This script will erase the registry key which contains the folder customization settings
' for the current user. This will force all folder customization settings for the current
' user to be set back to the defaults.
'==========================================================================
Option Explicit
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_USERS = &H80000003
Dim oShell, oFSO, oEnv, oNet, sSubKey, aSubKeys, s
Set oShell = CreateObject("Wscript.Shell")
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv").EnumKey _
HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\InternetRegistry\REGISTRY\USER", aSubKeys
For Each sSubKey In aSubKeys
fKillRegKey "HKEY_USERS\" & sSubkey & "_Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags"
Next
Function fKillRegKey(ByVal sKeyToDelete)
Dim aSubKeys, sSubKey, iSubkeyCheck, sKeyToKill, iElement
Dim aKeyPathSubSection, hKeyRoot, oWMIReg, strKeyRoot
aKeyPathSubSection = Split(sKeyToDelete, "\")
hKeyRoot = HKEY_USERS
strKeyRoot = "HKEY_USERS"
For iElement = 1 To UBound(aKeyPathSubSection)
sKeyToKill = sKeyToKill & "\" & aKeyPathSubSection(iElement)
Next
If Left(sKeyToKill,1) = "\" Then sKeyToKill = Right(sKeyToKill, Len(sKeyToKill)-1)
'Errors will be generated when there are no subkeys during recursion - this is normal and expected
On Error Resume Next
Set oWMIReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
iSubkeyCheck = oWMIReg.EnumKey(hKeyRoot, sKeyToKill, aSubKeys)
If iSubkeyCheck = 0 And IsArray(aSubKeys) Then
For Each sSubKey In aSubKeys
If Err.Number <> 0 Then
Err.Clear
Exit Function
End If
'Recursively call this function, to delete each subkey - and their subkeys, and so on...
fKillRegKey strKeyRoot & "\" & sKeyToKill & "\" & sSubKey
Next
End If
'if the key has no subkeys, delete it.
oShell.RegDelete strKeyRoot & "\" & sKeyToKill & "\"
End Function
Hope it helps someone else.
"Would you like to touch my monkey?" - Dieter (Mike Meyers)
"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury