{"id":280,"date":"2009-05-09T23:19:24","date_gmt":"2009-05-09T15:19:24","guid":{"rendered":"http:\/\/www.jhouseconsulting.com\/?p=280"},"modified":"2009-12-05T17:46:01","modified_gmt":"2009-12-05T09:46:01","slug":"mastering-the-default-explorer-views-for-windows-xp-and-2003","status":"publish","type":"post","link":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/2009\/05\/09\/mastering-the-default-explorer-views-for-windows-xp-and-2003-280","title":{"rendered":"Mastering the default Explorer views for Windows XP and 2003"},"content":{"rendered":"<p>I finally mastered the Windows Explorer views under Windows XP and 2003!<\/p>\n<p>The following script is fully documented.<\/p>\n<p>Enjoy!<!--more--><\/p>\n<p><dirtycode:SetExplorerViews.vbs><br \/>\n&#8216;================================================================================<br \/>\n&#8216;<br \/>\n&#8216; This script sets the Details view for all folders.<br \/>\n&#8216;<br \/>\n&#8216; Release 1.3 on 22nd April 2009.<br \/>\n&#8216; Created by Jeremy@jhouseconsulting.com on 6th February 2007.<br \/>\n&#8216;<br \/>\n&#8216; On a Per-User basis, folder views are managed under two registry keys:<br \/>\n&#8216; 1) Network Folders &#8211; HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell<br \/>\n&#8216; 2) Local Folders   &#8211; HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\ShellNoRoam<br \/>\n&#8216; Just so you don&#8217;t get confused let me explain that drive mappings are considered<br \/>\n&#8216; to be local folders. Network folders are UNC paths.<br \/>\n&#8216;<br \/>\n&#8216; How to configure the default Folder Type template for users<br \/>\n&#8216;   Create the AllFolders key under the following key:<br \/>\n&#8216;   &#8211; HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\ShellNoRoam\\Bags\\AllFolders<br \/>\n&#8216;   &#8211; Then create a Shell key under that.<br \/>\n&#8216;   &#8211; Set the following values&#8230;<br \/>\n&#8216;   &#8211; DWORD value WFlags set to 0<br \/>\n&#8216;   &#8211; DWORD value Mode set to 4<br \/>\n&#8216;   &#8211; String value vid set to &#8220;{137E7700-3573-11CF-AE69-08002B2E1262}&#8221;<br \/>\n&#8216;<br \/>\n&#8216; Note the following table can be used to configure the above values (WFlags<br \/>\n&#8216; should always be 0)<br \/>\n&#8216; View Mode vid<br \/>\n&#8216; Icons (medium) 1 {0057D0E0-3573-11CF-AE69-08002B2E1262}<br \/>\n&#8216; Icons (small) 2 {0057D0E0-3573-11CF-AE69-08002B2E1262}<br \/>\n&#8216; List 3 {0E1FA5E0-3573-11CF-AE69-08002B2E1262}<br \/>\n&#8216; Details 4 {137E7700-3573-11CF-AE69-08002B2E1262}<br \/>\n&#8216; Thumbnail 5 {8BEBB290-52D0-11D0-B7F4-00C04FD706EC}<br \/>\n&#8216; Tiles 6 {65F125E5-7BE1-4810-BA9D-D271C8432CE3}<br \/>\n&#8216; Filmstrip 7 {8EEFA624-D1E9-445B-94B7-74FBCE2EA11A}<br \/>\n&#8216;<br \/>\n&#8216; Note that if you don&#8217;t want to show the status bar in the default folder view<br \/>\n&#8216; create a Status DWORD value and set it to 0<br \/>\n&#8216;<br \/>\n&#8216; Rather than creating this individually for each user you may choose to create<br \/>\n&#8216; it globally by setting the exact same values in the HKEY_LOCAL_MACHINE registry<br \/>\n&#8216; hive instead. The ShellNoRoam key does not exist in the HKLM hive by default.<br \/>\n&#8216;<br \/>\n&#8216; This script will also set\/reset the view of any existing cached folders. To do<br \/>\n&#8216; this it uses WMI to enumerate all the registry subkeys under the following keys:<br \/>\n&#8216; &#8211; &#8220;HKCU\\Software\\Microsoft\\Windows\\ShellNoRoam\\Bags&#8221;<br \/>\n&#8216; &#8211; &#8220;HKCU\\Software\\Microsoft\\Windows\\Shell\\Bags&#8221;<br \/>\n&#8216;<br \/>\n&#8216; It then uses WMI to create\/modify the Mode and Vid values under the following<br \/>\n&#8216; keys, where Nodeslot_number is the enumerated subkey:<br \/>\n&#8216; &#8211; &#8220;HKCU\\Software\\Microsoft\\Windows\\ShellNoRoam\\Bags\\Nodeslot_number\\Shell&#8221;<br \/>\n&#8216; &#8211; &#8220;HKCU\\Software\\Microsoft\\Windows\\Shell\\Bags\\Nodeslot_number\\Shell&#8221;<br \/>\n&#8216;<br \/>\n&#8216; You can choose to leave existing folder views as they are by setting the<br \/>\n&#8216; blnChangeExistingFolders value to False. This allows users to change the view<br \/>\n&#8216; as they wish, without it being overwritten next time they log in.<br \/>\n&#8216;<br \/>\n&#8216; Note that you must close and reopen Windows Explorer to see the changes.<br \/>\n&#8216;<br \/>\n&#8216; Usage:<br \/>\n&#8216; cscript.exe \/\/nologo SetExplorerViews.vbs<br \/>\n&#8216;<br \/>\n&#8216; This script was based on&#8230;<br \/>\n&#8216; 1) A kixtart script written by Rick Mack.<br \/>\n&#8216; 2) A blog by Nicholas Dille from Sepago found here:<br \/>\n&#8216;    http:\/\/blogs.sepago.de\/nicholas\/2009\/02\/17\/preserving-windows-explorer-folder-views-in-roaming-profiles\/<br \/>\n&#8216; 3) An article by &#8220;Snakefoot&#8221; found here:<br \/>\n&#8216;    http:\/\/smallvoid.com\/article\/winnt-default-folder-view.html<br \/>\n&#8216;<br \/>\n&#8216;================================================================================<\/p>\n<p>Option Explicit<\/p>\n<p>Dim objShell, objReg, strComputer, strKeyRoot, strKeyPath, strValueName, strValue<br \/>\nDim Return, blnDebug, arrSubKeys, subkey, i, strSystemRoot, strCommandLine, strView<br \/>\nDim arrKeys, item, intMode, strVid, blnChangeExistingFolders<\/p>\n<p>Const HKEY_CURRENT_USER = &#038;H80000001<\/p>\n<p>blnDebug = False<\/p>\n<p>arrKeys = Array(&#8220;ShellNoRoam&#8221;,&#8221;Shell&#8221;)<\/p>\n<p>blnChangeExistingFolders = True<\/p>\n<p>&#8216; Set strView to either medium icons, small icons, list, details, thumbnail, tiles<br \/>\n&#8216; or filmstrip<br \/>\nstrView = &#8220;Details&#8221;<\/p>\n<p>&#8216; Folder View Mode Values under Bags\\Nodeslot_number\\Shell. All values are DWORD<br \/>\nSelect Case lcase(strView)<br \/>\n  Case &#8220;medium icons&#8221; &#8216;The view should display medium-size icons<br \/>\n    intMode = 1<br \/>\n    strVid = &#8220;{0057D0E0-3573-11CF-AE69-08002B2E1262}&#8221;<br \/>\n  Case &#8220;small icons&#8221; &#8216;The view should display small icons<br \/>\n    intMode = 2<br \/>\n    strVid = &#8220;{0057D0E0-3573-11CF-AE69-08002B2E1262}&#8221;<br \/>\n  Case &#8220;list&#8221; &#8216;Object names are displayed in a list view<br \/>\n    intMode = 3<br \/>\n    strVid = &#8220;{0E1FA5E0-3573-11CF-AE69-08002B2E1262}&#8221;<br \/>\n  Case &#8220;details&#8221; &#8216;Object names and other selected information, such as the size or date last updated, are shown<br \/>\n    intMode = 4<br \/>\n    strVid = &#8220;{137E7700-3573-11CF-AE69-08002B2E1262}&#8221;<br \/>\n  Case &#8220;thumbnail&#8221; &#8216;The view should display thumbnail icons<br \/>\n    intMode = 5<br \/>\n    strVid = &#8220;{8BEBB290-52D0-11D0-B7F4-00C04FD706EC}&#8221;<br \/>\n  Case &#8220;tiles&#8221; &#8216;The view should display large icons<br \/>\n    intMode = 6<br \/>\n    strVid = &#8220;{65F125E5-7BE1-4810-BA9D-D271C8432CE3}&#8221;<br \/>\n  Case &#8220;filmstrip&#8221; &#8216;The view should display icons in a filmstrip format<br \/>\n    intMode = 7<br \/>\n    strVid = &#8220;{8EEFA624-D1E9-445B-94B7-74FBCE2EA11A}&#8221;<br \/>\nEnd Select<\/p>\n<p>&#8216; FFlags Values under Bags\\Nodeslot_number\\Shell. All values are DWORD<br \/>\n&#8216; &#8211; Autoarrange_Off_Align_to_Grid_Off = 220<br \/>\n&#8216; &#8211; Autoarrange_On = 221<br \/>\n&#8216; &#8211; Autoarrange_off_Align_to_Grid_On = 224<br \/>\n&#8216; &#8211; Autoarrange_On_Align_to_Grid_On = 225<\/p>\n<p>&#8216; Sort Values under Bags\\Nodeslot_number\\Shell. All values are DWORD<br \/>\n&#8216; &#8211; Sort_by_Name = 0<br \/>\n&#8216; &#8211; Sort_by_Size = 1<br \/>\n&#8216; &#8211; Sort_by_Type = 2<br \/>\n&#8216; &#8211; Sort_By_Modified = 3<\/p>\n<p>strComputer = &#8220;.&#8221;<\/p>\n<p>Set objShell = WScript.CreateObject(&#8220;WScript.Shell&#8221;)<br \/>\nSet objReg = GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}!\\\\&#8221; &#038; _<br \/>\n    strComputer &#038; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyRoot = &#8220;HKCU\\&#8221;<br \/>\nstrKeyPath = &#8220;Software\\Microsoft\\Windows\\&#8221;<\/p>\n<p>&#8216; New profiles will not contain the key structure, so we need to create them.<br \/>\nFor Each item in arrKeys<br \/>\n  If NOT RegKeyExists(strKeyRoot &#038; strKeyPath &#038; item) Then<br \/>\n    Return = objReg.CreateKey (HKEY_CURRENT_USER,strKeyPath &#038; item)<br \/>\n    If blnDebug Then<br \/>\n      If (Return = 0) And (Err.Number = 0) Then<br \/>\n        Wscript.Echo &#8220;Create the &#8221; &#038; strKeyPath &#038; item &#038; &#8221; key.&#8221;<br \/>\n      Else<br \/>\n        Wscript.Echo &#8220;Could not create the &#8221; &#038; strKeyPath &#038; item &#038; &#8221; key.&#8221;<br \/>\n      End If<br \/>\n    End If<br \/>\n  End If<br \/>\n  If NOT RegKeyExists(strKeyRoot &#038; strKeyPath &#038; item &#038; &#8220;\\Bags&#8221;) Then<br \/>\n    Return = objReg.CreateKey (HKEY_CURRENT_USER,strKeyPath &#038; item &#038; &#8220;\\Bags&#8221;)<br \/>\n    If blnDebug Then<br \/>\n      If (Return = 0) And (Err.Number = 0) Then<br \/>\n        Wscript.Echo &#8220;Create the &#8221; &#038; strKeyPath &#038; item &#038; &#8220;\\Bags key.&#8221;<br \/>\n      Else<br \/>\n        Wscript.Echo &#8220;Could not create the &#8221; &#038; strKeyPath &#038; item &#038; &#8220;\\Bags key.&#8221;<br \/>\n      End If<br \/>\n    End If<br \/>\n  End If<br \/>\n  If NOT RegKeyExists(strKeyRoot &#038; strKeyPath &#038; item &#038; &#8220;\\BagMRU&#8221;) Then<br \/>\n    Return = objReg.CreateKey (HKEY_CURRENT_USER,strKeyPath &#038; item &#038; &#8220;\\BagMRU&#8221;)<br \/>\n    If blnDebug Then<br \/>\n      If (Return = 0) And (Err.Number = 0) Then<br \/>\n        Wscript.Echo &#8220;Create the &#8221; &#038; strKeyPath &#038; item &#038; &#8220;\\BagMRU key.&#8221;<br \/>\n      Else<br \/>\n        Wscript.Echo &#8220;Could not create the &#8221; &#038; strKeyPath &#038; item &#038; &#8220;\\BagMRU key.&#8221;<br \/>\n      End If<br \/>\n    End If<br \/>\n  End If<br \/>\nNext<\/p>\n<p>&#8216; The ShellNoRoam fix as per the Sepago article.<br \/>\nstrValueName = &#8220;&#8221;<br \/>\nstrValue = &#8220;%COMPUTERNAME%&#8221;<br \/>\nReturn = objReg.SetExpandedStringValue (HKEY_CURRENT_USER,strKeyPath &#038; &#8220;ShellNoRoam&#8221;,strValueName,strValue)<br \/>\nIf blnDebug Then<br \/>\n  If (Return = 0) And (Err.Number = 0) Then<br \/>\n    Wscript.Echo &#8220;SetExpandedStringValue succeeded&#8221;<br \/>\n  Else<br \/>\n    Wscript.Echo &#8220;SetExpandedStringValue failed. Error = &#8221; &#038; Err.Number<br \/>\n  End If<br \/>\nEnd If<\/p>\n<p>&#8216; Create the AllFolders key, and values within.<br \/>\nReturn = objReg.CreateKey (HKEY_CURRENT_USER,strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders&#8221;)<br \/>\nIf blnDebug Then<br \/>\n  If (Return = 0) And (Err.Number = 0) Then<br \/>\n    Wscript.Echo &#8220;Create the &#8221; &#038; strKeyPath &#038; &#8220;ShellNoRoam&#8221; &#038; &#8220;\\Bags\\AllFolders key.&#8221;<br \/>\n  Else<br \/>\n    Wscript.Echo &#8220;Could not create the &#8221; &#038; strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders key.&#8221;<br \/>\n  End If<br \/>\nEnd If<br \/>\nReturn = objReg.CreateKey (HKEY_CURRENT_USER,strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders\\Shell&#8221;)<br \/>\nIf blnDebug Then<br \/>\n  If (Return = 0) And (Err.Number = 0) Then<br \/>\n    Wscript.Echo &#8220;Create the &#8221; &#038; strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders\\Shell key.&#8221;<br \/>\n  Else<br \/>\n    Wscript.Echo &#8220;Could not create the &#8221; &#038; strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders\\Shell key.&#8221;<br \/>\n  End If<br \/>\nEnd If<br \/>\nReturn = objReg.SetDWORDValue (HKEY_CURRENT_USER,strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders\\Shell&#8221;,&#8221;WFlags&#8221;,0)<br \/>\nIf blnDebug Then<br \/>\n  If (Return = 0) And (Err.Number = 0) Then<br \/>\n    Wscript.Echo &#8220;SetDWORDValue succeeded&#8221;<br \/>\n  Else<br \/>\n    Wscript.Echo &#8220;SetDWORDValue failed. Error = &#8221; &#038; Err.Number<br \/>\n  End If<br \/>\nEnd If<br \/>\nReturn = objReg.SetDWORDValue (HKEY_CURRENT_USER,strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders\\Shell&#8221;,&#8221;Mode&#8221;,intMode)<br \/>\nIf blnDebug Then<br \/>\n  If (Return = 0) And (Err.Number = 0) Then<br \/>\n    Wscript.Echo &#8220;SetDWORDValue succeeded&#8221;<br \/>\n  Else<br \/>\n    Wscript.Echo &#8220;SetDWORDValue failed. Error = &#8221; &#038; Err.Number<br \/>\n  End If<br \/>\nEnd If<br \/>\nReturn = objReg.SetStringValue (HKEY_CURRENT_USER,strKeyPath &#038; &#8220;ShellNoRoam\\Bags\\AllFolders\\Shell&#8221;,&#8221;Vid&#8221;,strVid)<br \/>\nIf blnDebug Then<br \/>\n  If (Return = 0) And (Err.Number = 0) Then<br \/>\n    Wscript.Echo &#8220;SetStringValue succeeded&#8221;<br \/>\n  Else<br \/>\n    Wscript.Echo &#8220;SetStringValue failed. Error = &#8221; &#038; Err.Number<br \/>\n  End If<br \/>\nEnd If<\/p>\n<p>&#8216; Enumerate and change existing folder values.<br \/>\nIf blnChangeExistingFolders Then<br \/>\n  For Each item in arrKeys<br \/>\n    Return = objReg.EnumKey (HKEY_CURRENT_USER, strKeyPath &#038; item &#038; &#8220;\\Bags&#8221;, arrSubKeys)<br \/>\n    If blnDebug Then<br \/>\n      If (Return = 0) And (Err.Number = 0) Then<br \/>\n        Wscript.Echo &#8220;EnumKey succeeded&#8221;<br \/>\n      Else<br \/>\n        Wscript.Echo &#8220;EnumKey failed. Error = &#8221; &#038; Err.Number<br \/>\n      End If<br \/>\n    End If<br \/>\n    If blnDebug Then<br \/>\n&#8216;     The next three lines for debugging purposes only to display the contents of<br \/>\n&#8216;     the array elements.<br \/>\n      For i = 0 to UBound(arrSubKeys)<br \/>\n        Wscript.echo &#8220;Array element &#8221; &#038; i &#038; &#8221; contains a value of &#8221; &#038; arrSubKeys(i)<br \/>\n      Next<br \/>\n    End If<br \/>\n    If IsArray(arrSubKeys) Then<br \/>\n      For Each subkey In arrSubKeys<br \/>\n        Return = objReg.SetDWORDValue (HKEY_CURRENT_USER,strKeyPath &#038; item &#038; &#8220;\\Bags\\&#8221; &#038; subkey &#038; &#8220;\\&#8221; &#038; &#8220;Shell&#8221;,&#8221;Mode&#8221;,intMode)<br \/>\n        If blnDebug Then<br \/>\n          If (Return = 0) And (Err.Number = 0) Then<br \/>\n            Wscript.Echo &#8220;SetDWORDValue succeeded&#8221;<br \/>\n          Else<br \/>\n            Wscript.Echo &#8220;SetDWORDValue failed. Error = &#8221; &#038; Err.Number<br \/>\n          End If<br \/>\n        End If<br \/>\n        Return = objReg.SetStringValue (HKEY_CURRENT_USER,strKeyPath &#038; item &#038; &#8220;\\Bags\\&#8221; &#038; subkey &#038; &#8220;\\&#8221; &#038; &#8220;Shell&#8221;,&#8221;Vid&#8221;,strVid)<br \/>\n        If blnDebug Then<br \/>\n          If (Return = 0) And (Err.Number = 0) Then<br \/>\n            Wscript.Echo &#8220;SetStringValue succeeded&#8221;<br \/>\n          Else<br \/>\n            Wscript.Echo &#8220;SetStringValue failed. Error = &#8221; &#038; Err.Number<br \/>\n          End If<br \/>\n        End If<br \/>\n      Next<br \/>\n    End If<br \/>\n  Next<br \/>\nEnd If<\/p>\n<p>Set objShell = Nothing<br \/>\nSet objReg = Nothing<\/p>\n<p>WScript.Quit(0)<\/p>\n<p>Function RegKeyExists(ByVal sRegKey)<br \/>\n&#8216; Returns True or False based on the existence of a registry key.<br \/>\n  Dim sDescription, oShell<br \/>\n  Set oShell = CreateObject(&#8220;WScript.Shell&#8221;)<br \/>\n  RegKeyExists = True<br \/>\n  sRegKey = Trim (sRegKey)<br \/>\n  If Not Right(sRegKey, 1) = &#8220;\\&#8221; Then<br \/>\n    sRegKey = sRegKey &#038; &#8220;\\&#8221;<br \/>\n  End If<br \/>\n  On Error Resume Next<br \/>\n  oShell.RegRead &#8220;HKEYNotAKey\\&#8221;<br \/>\n  sDescription = Replace(Err.Description, &#8220;HKEYNotAKey\\&#8221;, &#8220;&#8221;)<br \/>\n  Err.Clear<br \/>\n  oShell.RegRead sRegKey<br \/>\n  RegKeyExists = sDescription <> Replace(Err.Description, sRegKey, &#8220;&#8221;)<br \/>\n  On Error Goto 0<br \/>\n  Set oShell = Nothing<br \/>\nEnd Function<br \/>\n<\/dirtycode><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally mastered the Windows Explorer views under Windows XP and 2003! The following script is fully documented. Enjoy!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[5],"tags":[129],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-scripting","tag-windows-explorer-views"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/comments?post=280"}],"version-history":[{"count":6,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":282,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/posts\/280\/revisions\/282"}],"wp:attachment":[{"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/media?parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/categories?post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jhouseconsulting.com\/jhouseconsulting\/wp-json\/wp\/v2\/tags?post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}