This is a multi-part message in MIME format.

------=_NextPart_000_01A3_01C526AA.CB4F12E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,
I've written this script to allow users to customize a view for a =
folder and then apply to all the subfolders. I thought I'd post it here =
first for comments and suggestions. It's not very robust with error =
handling :). It will hang if it runs into a folder with access denied. =
Can the gurus here take a look and help me tweak it before posting to =
the customize and music folk? I'm especially wondering about how to =
handle the timing in the OpenAndCloseSubfolders function. The loop I =
have now seems to be faster than using a sleep statement. I've left in =
a msgbox reporting execution time for the function which I plan to take =
out before the big rollout :)

Thanks to all ,
Keith

P.S. I know some people hate it, but I'm attaching the file as text as =
well because of line-wrapping concerns.

##########################################################
Const conBagMRUPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"
Const conBagsPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
Const conFolderStreams =3D =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults=
\{F3364BA0-65B9-11CE-A9BA-00AA0=AD04AE837}"
Const ForReading =3D 1

dim oAppShell, oScriptShell, oFso, oFolder
dim VPathCollection ()
dim sIntroMsg, sScriptTitle, sIntro2, sSetView

'Instructions & Warnings
InitMsgStrs
If (msgbox(sIntroMsg, vbYesNo, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
If (msgbox(sIntro2, vbYesNo + vbCritical, sScriptTitle) <> vbYes) Then
WScript.Quit
End If

'Assign objects
Set oAppShell =3D CreateObject("Shell.Application")
Set oScriptShell =3D CreateObject("WScript.Shell")=20
Set oFSO =3D CreateObject("Scripting.FileSystemObject")

'Verify other windows are closed
Do While oAppShell.windows.count <> 0
If (msgbox(oAppShell.windows.count & " Explorer/I.E. windows are =
still open!", _
vbRetryCancel + vbCritical, sScriptTitle) <> vbReTry) Then
WScript.Quit
End If
Loop

'Back up the Registry Keys
Call RegExport(conBagMRUPath, "BagMRU Backup.reg")
Call RegExport(conBagsPath, "Bags Backup.reg")

DeleteBagsAndIncreaseLimit
'If conFolderStreams exists,it screws up the
' default columns for detail view of special folders. So...
On Error Resume Next
oScriptShell.RegDelete conFolderStreams
Err.Clear
On Error Goto 0

iNewBagCount =3D 0
bContinue =3D True
iLoopCount =3D 0

Do While bContinue '*** The Fun Starts Here ***
iLoopCount =3D iLoopCount + 1
set oFolder =3D oAppShell.BrowseForFolder(0, "Choose a Folder", 0)
oAppShell.Open oFolder
WScript.Sleep 1000
msgbox sSetView,,oFolder.title & " - Script Paused..."
oAppShell.windows.item.quit
iNewBagCount =3D iNewBagCount + 1

ReDim Preserve VPathCollection(iLoopCount - 1)
VPathCollection(iLoopCount - 1) =3D VPath(oFolder)
sFolderTemplateFile =3D MakeFolderTemplate(iNewBagCount)

RegImport sFolderTemplateFile

sStart =3D Now
iNewBagCount =3D iNewBagCount + OpenAndCloseSubfolders(oFolder)
MsgBox "Finished in " & DateDiff("s", sStart, Now) & " seconds", _=20
vbSystemModal, "OpenAndCloseSubfolders"


oFso.GetFile(sFolderTemplateFile).Delete
oScriptShell.RegDelete(conBagsPath & "\AllFolders\Shell\")
oScriptShell.RegDelete(conBagsPath & "\AllFolders\")

msg =3D "You have saved views for the following folder(s):" & vbCrLf
For each sPath in VPathCollection
msg =3D msg & vbTab & sPath & vbCrLf
Next
msg =3D msg & "You have saved views for " & iNewBagCount & " folders =
(8000 max)" & vbCrLf
msg =3D msg & vbCrLf & "Would you like to do another folder?"
bcontinue =3D msgbox (msg, vbYesNo) =3D vbYes
Loop

Set oAppShell =3D Nothing
Set oScriptShell =3D Nothing
Set oFSO =3D Nothing

'---------------------------------------End------------------------------=
-----

Function MakeFolderTemplate (iBagNum)
Dim sTemplateRegPath, sTemplateFileName, sFolderTemplate, ts

sTemplateRegPath =3D conBagsPath & "\" & iBagNum
sTemplateFileName =3D "Folder Template" & iBagNum & ".reg"
sFolderTemplate =3D RegExport (sTemplateRegPath, sTemplateFileName)
'msgbox sFolderTemplate
Set ts =3D oFso.OpenTextFile(sFolderTemplate, ForReading)
sTemplateInfo =3D ts.ReadAll
ts.close

sSearch =3D "Bags\" & iNewBagCount
sReplace =3D "Bags\AllFolders"
sTemplateInfo =3D Replace (sTemplateInfo, sSearch, sReplace, 1, 2)
sTemplateInfo =3D Replace (sTemplateInfo, "My", "")

Set ts =3D oFso.CreateTextFile (sFolderTemplate, true)
ts.Write sTemplateInfo
ts.Close

Set ts =3D Nothing
MakeFolderTemplate =3D sFolderTemplate =20
End Function

'----------------------------------------

Function OpenAndCloseSubfolders (oFolder)
Dim iCount
iCount=3D0
For Each oItem in oFolder.Items
If oItem.IsFolder Then
If NotZipped(oItem) and NotAlreadySaved(oItem) Then
'Do Until oAppshell.windows.count =3D 0
' WScript.Sleep 100
'Loop
oAppshell.open oItem.GetFolder
'WScript.Sleep 1000
On Error Resume Next
Do
Err.Clear
oAppshell.windows.item.quit
Loop Until Err.Number =3D 0
iCount =3D iCount + 1
iCount =3D iCount + =
OpenAndCloseSubfolders(oItem.GetFolder)
End If
End If
Next
OpenAndCloseSubfolders =3D iCount
End Function

'-----------------------------------------

Sub DeleteBagsAndIncreaseLimit ()
Dim tFolder, tName, tFile, tString
Const TemporaryFolder =3D 2
Set tFolder =3D oFso.GetSpecialFolder(TemporaryFolder)

tName =3D oFso.GetTempName =20
Set tFile =3D tFolder.CreateTextFile(tName)
tString =3D _
"REGEDIT4" & vbCrLf & vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU]" =
& vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags]" & =
vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell]" & vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam]" & =
vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
=
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Ex=
plorer]" & vbCrLf & _
"""NoSaveSettings""=3Ddword:00000000" & vbCrLf & vbCrLf
tFile.write (tString)
tFile.close
RegImport (tFolder.Path & "\" & tName)
oFso.GetFile(tFolder.Path & "\" & tName).Delete
End Sub =20

'-----------------------------------------

Sub RegImport (sFileName)
Dim sCmd
sCmd =3D "regedit.exe /s """ & sFileName & """"
oScriptShell.Run sCmd, 0, True
End Sub

'-----------------------------------------

Function RegExport (sRegPath, sFileName)
Dim sCmd, sTemp
sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
oScriptShell.Run sCmd, 0, True
RegExport =3D sTemp
End Function

'-----------------------------------------

Function NotZipped (oFolder)
NotZipped =3D Not (CBool (InStr (oFolder.type, "zipped")))
End Function

'-----------------------------------------

Function VPath (oFolder)
on error resume next
sTemp =3D oFolder.ParentFolder.title
If Err.Number =3D 0 then=20
VPath =3D VPath (oFolder.ParentFolder) & "\" & oFolder.title
Else
VPath =3D oFolder.title
Err.Clear
End If
End Function

'-----------------------------------------

Function NotAlreadySaved (oFolder)
Dim sVPath
NotAlreadySaved =3D True
sVPath =3D VPath (oFolder.GetFolder)
For Each s in VPathCollection
If s =3D sVPath Then
NotAlreadySaved =3D False
Exit For
End If
Next
End Function

'-----------------------------------------

Sub InitMsgStrs ()
sIntroMsg =3D "This script will allow you to customize the view for =
a folder and " & _
"then have that view applied to all of the folder's subfolders. =
" & _
"All previously saved views will be lost. Your old settings " & =
_
"will be saved in two .reg files placed on the desktop that can =
be " & _
"merged to restore your old settings." & vbCrLf & vbCrLf & _
"Work your way up from lower-level folders to higher-level " & _
"folders -- i.e. do My Music and My Pictures before doing My =
Documents. " & _
"If a sub-folder has already had a view saved, It will not be =
affected by " & _
"applying a different view to its parent folder." & vbCrLf & =
vbCrLf & _
"Also, different views are saved for 'My Documents' and its " & =
_
"subfolders, depending on how they are accessed:" & vbCrLf & =
vbCrLf & _
vbTab & "'Desktop\My Documents'" & vbCrLf & vbTab & "'My =
Computer\My Documents'" & _
vbCrLf & vbTab & "'C:\Docs and Settings\<username>\My =
Documents'" & vbCrLf & _
vbCrLf & "are seperate and unique as far as views are concerned. =
You may want " & _
"to take a minute to verify which way you access these folders =
by opening one " & _
"and viewing the folder pane to determine the path." & vbCrLf & =
vbCrLf & _
"Do you wish to continue?"
sScriptTitle =3D "Customize Folder Views"
sIntro2 =3D "This script will be opening and closing explorer =
windows in order to " & _
"apply the views. It is recommended you close other =
applications to run " & _
"this Script. To function properly, It is IMPERATIVE that you =
not have " & _
"any Explorer or I.E. windows open. If you have any open, =
please close " & _
"them before clicking 'OK'" & vbCrLf & vbCrLf & "Do you wish to =
continue?"
sSetView =3D "Alt+Tab to the Folder window now open and set all view =
options to your " & _
"liking. DO NOT CLOSE THE FOLDER YOURSELF! When you are done, =
Alt+Tab back to this window & click 'OK'."=20
End Sub

------=_NextPart_000_01A3_01C526AA.CB4F12E0
Content-Type: text/plain;
name="FolderViewSave.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="FolderViewSave.txt"

Const conBagMRUPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"
Const conBagsPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
Const conFolderStreams =3D =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults=
\{F3364BA0-65B9-11CE-A9BA-00AA0=AD04AE837}"
Const ForReading =3D 1

dim oAppShell, oScriptShell, oFso, oFolder
dim VPathCollection ()
dim sIntroMsg, sScriptTitle, sIntro2, sSetView

'Instructions & Warnings
InitMsgStrs
If (msgbox(sIntroMsg, vbYesNo, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
If (msgbox(sIntro2, vbYesNo + vbCritical, sScriptTitle) <> vbYes) Then
WScript.Quit
End If

'Assign objects
Set oAppShell =3D CreateObject("Shell.Application")
Set oScriptShell =3D CreateObject("WScript.Shell")=20
Set oFSO =3D CreateObject("Scripting.FileSystemObject")

'Verify other windows are closed
Do While oAppShell.windows.count <> 0
If (msgbox(oAppShell.windows.count & " Explorer/I.E. windows are =
still open!", _
vbRetryCancel + vbCritical, sScriptTitle) <> vbReTry) Then
WScript.Quit
End If
Loop
=20
'Back up the Registry Keys
Call RegExport(conBagMRUPath, "BagMRU Backup.reg")
Call RegExport(conBagsPath, "Bags Backup.reg")

DeleteBagsAndIncreaseLimit
'If conFolderStreams exists,it screws up the
' default columns for detail view of special folders. So...
On Error Resume Next
oScriptShell.RegDelete conFolderStreams
Err.Clear
On Error Goto 0

iNewBagCount =3D 0
bContinue =3D True
iLoopCount =3D 0

Do While bContinue '*** The Fun Starts Here ***
iLoopCount =3D iLoopCount + 1
set oFolder =3D oAppShell.BrowseForFolder(0, "Choose a Folder", 0)
oAppShell.Open oFolder
WScript.Sleep 1000
msgbox sSetView,,oFolder.title & " - Script Paused..."
oAppShell.windows.item.quit
iNewBagCount =3D iNewBagCount + 1

ReDim Preserve VPathCollection(iLoopCount - 1)
VPathCollection(iLoopCount - 1) =3D VPath(oFolder)
sFolderTemplateFile =3D MakeFolderTemplate(iNewBagCount)

RegImport sFolderTemplateFile

sStart =3D Now
iNewBagCount =3D iNewBagCount + OpenAndCloseSubfolders(oFolder)
MsgBox "Finished in " & DateDiff("s", sStart, Now) & " seconds", _=20
vbSystemModal, "OpenAndCloseSubfolders"


oFso.GetFile(sFolderTemplateFile).Delete
oScriptShell.RegDelete(conBagsPath & "\AllFolders\Shell\")
oScriptShell.RegDelete(conBagsPath & "\AllFolders\")

msg =3D "You have saved views for the following folder(s):" & vbCrLf
For each sPath in VPathCollection
msg =3D msg & vbTab & sPath & vbCrLf
Next
msg =3D msg & "You have saved views for " & iNewBagCount & " folders =
(8000 max)" & vbCrLf
msg =3D msg & vbCrLf & "Would you like to do another folder?"
bcontinue =3D msgbox (msg, vbYesNo) =3D vbYes
Loop

Set oAppShell =3D Nothing
Set oScriptShell =3D Nothing
Set oFSO =3D Nothing

'---------------------------------------End------------------------------=
-----------

Function MakeFolderTemplate (iBagNum)
Dim sTemplateRegPath, sTemplateFileName, sFolderTemplate, ts

sTemplateRegPath =3D conBagsPath & "\" & iBagNum
sTemplateFileName =3D "Folder Template" & iBagNum & ".reg"
sFolderTemplate =3D RegExport (sTemplateRegPath, sTemplateFileName)
'msgbox sFolderTemplate
Set ts =3D oFso.OpenTextFile(sFolderTemplate, ForReading)
sTemplateInfo =3D ts.ReadAll
ts.close

sSearch =3D "Bags\" & iNewBagCount
sReplace =3D "Bags\AllFolders"
sTemplateInfo =3D Replace (sTemplateInfo, sSearch, sReplace, 1, 2)
sTemplateInfo =3D Replace (sTemplateInfo, "My", "")

Set ts =3D oFso.CreateTextFile (sFolderTemplate, true)
ts.Write sTemplateInfo
ts.Close

Set ts =3D Nothing
MakeFolderTemplate =3D sFolderTemplate =20
End Function

'----------------------------------------

Function OpenAndCloseSubfolders (oFolder)
Dim iCount
iCount=3D0
For Each oItem in oFolder.Items
If oItem.IsFolder Then
If NotZipped(oItem) and NotAlreadySaved(oItem) Then
'Do Until oAppshell.windows.count =3D 0
' WScript.Sleep 100
'Loop
oAppshell.open oItem.GetFolder
'WScript.Sleep 1000
On Error Resume Next
Do
Err.Clear
oAppshell.windows.item.quit
Loop Until Err.Number =3D 0
iCount =3D iCount + 1
iCount =3D iCount + =
OpenAndCloseSubfolders(oItem.GetFolder)
End If
End If
Next
OpenAndCloseSubfolders =3D iCount
End Function

'-----------------------------------------

Sub DeleteBagsAndIncreaseLimit ()
Dim tFolder, tName, tFile, tString
Const TemporaryFolder =3D 2
Set tFolder =3D oFso.GetSpecialFolder(TemporaryFolder)

tName =3D oFso.GetTempName =20
Set tFile =3D tFolder.CreateTextFile(tName)
tString =3D _
"REGEDIT4" & vbCrLf & vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU]" =
& vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags]" & =
vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell]" & vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam]" & =
vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
=
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Ex=
plorer]" & vbCrLf & _
"""NoSaveSettings""=3Ddword:00000000" & vbCrLf & vbCrLf
tFile.write (tString)
tFile.close
RegImport (tFolder.Path & "\" & tName)
oFso.GetFile(tFolder.Path & "\" & tName).Delete
End Sub =20

'-----------------------------------------

Sub RegImport (sFileName)
Dim sCmd
sCmd =3D "regedit.exe /s """ & sFileName & """"
oScriptShell.Run sCmd, 0, True
End Sub

'-----------------------------------------

Function RegExport (sRegPath, sFileName)
Dim sCmd, sTemp
sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
oScriptShell.Run sCmd, 0, True
RegExport =3D sTemp
End Function

'-----------------------------------------

Function NotZipped (oFolder)
NotZipped =3D Not (CBool (InStr (oFolder.type, "zipped")))
End Function

'-----------------------------------------

Function VPath (oFolder)
on error resume next
sTemp =3D oFolder.ParentFolder.title
If Err.Number =3D 0 then=20
VPath =3D VPath (oFolder.ParentFolder) & "\" & oFolder.title
Else
VPath =3D oFolder.title
Err.Clear
End If
End Function

'-----------------------------------------

Function NotAlreadySaved (oFolder)
Dim sVPath
NotAlreadySaved =3D True
sVPath =3D VPath (oFolder.GetFolder)
For Each s in VPathCollection
If s =3D sVPath Then
NotAlreadySaved =3D False
Exit For
End If
Next =20
End Function

'-----------------------------------------

Sub InitMsgStrs ()
sIntroMsg =3D "This script will allow you to customize the view for =
a folder and " & _
"then have that view applied to all of the folder's subfolders. =
" & _
"All previously saved views will be lost. Your old settings " & =
_
"will be saved in two .reg files placed on the desktop that can =
be " & _
"merged to restore your old settings." & vbCrLf & vbCrLf & _
"Work your way up from lower-level folders to higher-level " & _
"folders -- i.e. do My Music and My Pictures before doing My =
Documents. " & _
"If a sub-folder has already had a view saved, It will not be =
affected by " & _
"applying a different view to its parent folder." & vbCrLf & =
vbCrLf & _
"Also, different views are saved for 'My Documents' and its " & =
_
"subfolders, depending on how they are accessed:" & vbCrLf & =
vbCrLf & _
vbTab & "'Desktop\My Documents'" & vbCrLf & vbTab & "'My =
Computer\My Documents'" & _
vbCrLf & vbTab & "'C:\Docs and Settings\<username>\My =
Documents'" & vbCrLf & _
vbCrLf & "are seperate and unique as far as views are concerned. =
You may want " & _
"to take a minute to verify which way you access these folders =
by opening one " & _
"and viewing the folder pane to determine the path." & vbCrLf & =
vbCrLf & _
"Do you wish to continue?"
sScriptTitle =3D "Customize Folder Views"
sIntro2 =3D "This script will be opening and closing explorer =
windows in order to " & _
"apply the views. It is recommended you close other =
applications to run " & _
"this Script. To function properly, It is IMPERATIVE that you =
not have " & _
"any Explorer or I.E. windows open. If you have any open, =
please close " & _
"them before clicking 'OK'" & vbCrLf & vbCrLf & "Do you wish to =
continue?"
sSetView =3D "Alt+Tab to the Folder window now open and set all view =
options to your " & _
"liking. DO NOT CLOSE THE FOLDER YOURSELF! When you are done, =
Alt+Tab back to this window & click 'OK'."=20
End Sub

------=_NextPart_000_01A3_01C526AA.CB4F12E0--

Re: Script for Folder View Customization - Beta by Keith

Keith
Sat Mar 12 14:46:46 CST 2005

I've rewritten the OpenAndCloseSubfolders function to handle 'access =
denied' issues:

Function OpenAndCloseSubfolders (oFolder)
Dim iCount
iCount=3D0
For Each oItem in oFolder.Items
If oItem.IsFolder Then
If NotZipped(oItem) and NotAlreadySaved(oItem) Then
iCount =3D iCount + =
OpenAndCloseSubfolders(oItem.GetFolder)
'**Check for folder access permission
On Error Resume Next
dummy =3D oFSO.getfolder(oItem.path).size
If Err.Number <> 0 Then
Err.Clear
On Error Goto 0
Else
On Error Goto 0
'Do Until oAppshell.windows.count =3D 0
' WScript.Sleep 100
'Loop
oAppshell.open oItem.GetFolder
'WScript.Sleep 1000
On Error Resume Next
Do
Err.Clear
oAppshell.windows.item.quit
Loop Until Err.Number =3D 0
iCount =3D iCount + 1
End If
End If
End If
Next
OpenAndCloseSubfolders =3D iCount
End Function


"Keith Miller" <k.miller79@verizon.net> wrote in message =
news:%23QwwV0tJFHA.1172@TK2MSFTNGP12.phx.gbl...
Hi all,
I've written this script to allow users to customize a view for a =
folder and then apply to all the subfolders. I thought I'd post it here =
first for comments and suggestions. It's not very robust with error =
handling :). It will hang if it runs into a folder with access denied. =
Can the gurus here take a look and help me tweak it before posting to =
the customize and music folk? I'm especially wondering about how to =
handle the timing in the OpenAndCloseSubfolders function. The loop I =
have now seems to be faster than using a sleep statement. I've left in =
a msgbox reporting execution time for the function which I plan to take =
out before the big rollout :)

Thanks to all ,
Keith

P.S. I know some people hate it, but I'm attaching the file as text as =
well because of line-wrapping concerns.

##########################################################
Const conBagMRUPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"
Const conBagsPath =3D =
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
Const conFolderStreams =3D =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults=
\{F3364BA0-65B9-11CE-A9BA-00AA0=AD04AE837}"
Const ForReading =3D 1

dim oAppShell, oScriptShell, oFso, oFolder
dim VPathCollection ()
dim sIntroMsg, sScriptTitle, sIntro2, sSetView

'Instructions & Warnings
InitMsgStrs
If (msgbox(sIntroMsg, vbYesNo, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
If (msgbox(sIntro2, vbYesNo + vbCritical, sScriptTitle) <> vbYes) Then
WScript.Quit
End If

'Assign objects
Set oAppShell =3D CreateObject("Shell.Application")
Set oScriptShell =3D CreateObject("WScript.Shell")=20
Set oFSO =3D CreateObject("Scripting.FileSystemObject")

'Verify other windows are closed
Do While oAppShell.windows.count <> 0
If (msgbox(oAppShell.windows.count & " Explorer/I.E. windows are =
still open!", _
vbRetryCancel + vbCritical, sScriptTitle) <> vbReTry) Then
WScript.Quit
End If
Loop

'Back up the Registry Keys
Call RegExport(conBagMRUPath, "BagMRU Backup.reg")
Call RegExport(conBagsPath, "Bags Backup.reg")

DeleteBagsAndIncreaseLimit
'If conFolderStreams exists,it screws up the
' default columns for detail view of special folders. So...
On Error Resume Next
oScriptShell.RegDelete conFolderStreams
Err.Clear
On Error Goto 0

iNewBagCount =3D 0
bContinue =3D True
iLoopCount =3D 0

Do While bContinue '*** The Fun Starts Here ***
iLoopCount =3D iLoopCount + 1
set oFolder =3D oAppShell.BrowseForFolder(0, "Choose a Folder", 0)
oAppShell.Open oFolder
WScript.Sleep 1000
msgbox sSetView,,oFolder.title & " - Script Paused..."
oAppShell.windows.item.quit
iNewBagCount =3D iNewBagCount + 1

ReDim Preserve VPathCollection(iLoopCount - 1)
VPathCollection(iLoopCount - 1) =3D VPath(oFolder)
sFolderTemplateFile =3D MakeFolderTemplate(iNewBagCount)

RegImport sFolderTemplateFile

sStart =3D Now
iNewBagCount =3D iNewBagCount + OpenAndCloseSubfolders(oFolder)
MsgBox "Finished in " & DateDiff("s", sStart, Now) & " seconds", _=20
vbSystemModal, "OpenAndCloseSubfolders"


oFso.GetFile(sFolderTemplateFile).Delete
oScriptShell.RegDelete(conBagsPath & "\AllFolders\Shell\")
oScriptShell.RegDelete(conBagsPath & "\AllFolders\")

msg =3D "You have saved views for the following folder(s):" & vbCrLf
For each sPath in VPathCollection
msg =3D msg & vbTab & sPath & vbCrLf
Next
msg =3D msg & "You have saved views for " & iNewBagCount & " folders =
(8000 max)" & vbCrLf
msg =3D msg & vbCrLf & "Would you like to do another folder?"
bcontinue =3D msgbox (msg, vbYesNo) =3D vbYes
Loop

Set oAppShell =3D Nothing
Set oScriptShell =3D Nothing
Set oFSO =3D Nothing

'---------------------------------------End------------------------------=
-----

Function MakeFolderTemplate (iBagNum)
Dim sTemplateRegPath, sTemplateFileName, sFolderTemplate, ts

sTemplateRegPath =3D conBagsPath & "\" & iBagNum
sTemplateFileName =3D "Folder Template" & iBagNum & ".reg"
sFolderTemplate =3D RegExport (sTemplateRegPath, sTemplateFileName)
'msgbox sFolderTemplate
Set ts =3D oFso.OpenTextFile(sFolderTemplate, ForReading)
sTemplateInfo =3D ts.ReadAll
ts.close

sSearch =3D "Bags\" & iNewBagCount
sReplace =3D "Bags\AllFolders"
sTemplateInfo =3D Replace (sTemplateInfo, sSearch, sReplace, 1, 2)
sTemplateInfo =3D Replace (sTemplateInfo, "My", "")

Set ts =3D oFso.CreateTextFile (sFolderTemplate, true)
ts.Write sTemplateInfo
ts.Close

Set ts =3D Nothing
MakeFolderTemplate =3D sFolderTemplate =20
End Function

'----------------------------------------

Function OpenAndCloseSubfolders (oFolder)
Dim iCount
iCount=3D0
For Each oItem in oFolder.Items
If oItem.IsFolder Then
If NotZipped(oItem) and NotAlreadySaved(oItem) Then
'Do Until oAppshell.windows.count =3D 0
' WScript.Sleep 100
'Loop
oAppshell.open oItem.GetFolder
'WScript.Sleep 1000
On Error Resume Next
Do
Err.Clear
oAppshell.windows.item.quit
Loop Until Err.Number =3D 0
iCount =3D iCount + 1
iCount =3D iCount + =
OpenAndCloseSubfolders(oItem.GetFolder)
End If
End If
Next
OpenAndCloseSubfolders =3D iCount
End Function

'-----------------------------------------

Sub DeleteBagsAndIncreaseLimit ()
Dim tFolder, tName, tFile, tString
Const TemporaryFolder =3D 2
Set tFolder =3D oFso.GetSpecialFolder(TemporaryFolder)

tName =3D oFso.GetTempName =20
Set tFile =3D tFolder.CreateTextFile(tName)
tString =3D _
"REGEDIT4" & vbCrLf & vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU]" =
& vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags]" & =
vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell]" & vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam]" & =
vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
=
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Ex=
plorer]" & vbCrLf & _
"""NoSaveSettings""=3Ddword:00000000" & vbCrLf & vbCrLf
tFile.write (tString)
tFile.close
RegImport (tFolder.Path & "\" & tName)
oFso.GetFile(tFolder.Path & "\" & tName).Delete
End Sub =20

'-----------------------------------------

Sub RegImport (sFileName)
Dim sCmd
sCmd =3D "regedit.exe /s """ & sFileName & """"
oScriptShell.Run sCmd, 0, True
End Sub

'-----------------------------------------

Function RegExport (sRegPath, sFileName)
Dim sCmd, sTemp
sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
oScriptShell.Run sCmd, 0, True
RegExport =3D sTemp
End Function

'-----------------------------------------

Function NotZipped (oFolder)
NotZipped =3D Not (CBool (InStr (oFolder.type, "zipped")))
End Function

'-----------------------------------------

Function VPath (oFolder)
on error resume next
sTemp =3D oFolder.ParentFolder.title
If Err.Number =3D 0 then=20
VPath =3D VPath (oFolder.ParentFolder) & "\" & oFolder.title
Else
VPath =3D oFolder.title
Err.Clear
End If
End Function

'-----------------------------------------

Function NotAlreadySaved (oFolder)
Dim sVPath
NotAlreadySaved =3D True
sVPath =3D VPath (oFolder.GetFolder)
For Each s in VPathCollection
If s =3D sVPath Then
NotAlreadySaved =3D False
Exit For
End If
Next
End Function

'-----------------------------------------

Sub InitMsgStrs ()
sIntroMsg =3D "This script will allow you to customize the view for =
a folder and " & _
"then have that view applied to all of the folder's subfolders. =
" & _
"All previously saved views will be lost. Your old settings " & =
_
"will be saved in two .reg files placed on the desktop that can =
be " & _
"merged to restore your old settings." & vbCrLf & vbCrLf & _
"Work your way up from lower-level folders to higher-level " & _
"folders -- i.e. do My Music and My Pictures before doing My =
Documents. " & _
"If a sub-folder has already had a view saved, It will not be =
affected by " & _
"applying a different view to its parent folder." & vbCrLf & =
vbCrLf & _
"Also, different views are saved for 'My Documents' and its " & =
_
"subfolders, depending on how they are accessed:" & vbCrLf & =
vbCrLf & _
vbTab & "'Desktop\My Documents'" & vbCrLf & vbTab & "'My =
Computer\My Documents'" & _
vbCrLf & vbTab & "'C:\Docs and Settings\<username>\My =
Documents'" & vbCrLf & _
vbCrLf & "are seperate and unique as far as views are concerned. =
You may want " & _
"to take a minute to verify which way you access these folders =
by opening one " & _
"and viewing the folder pane to determine the path." & vbCrLf & =
vbCrLf & _
"Do you wish to continue?"
sScriptTitle =3D "Customize Folder Views"
sIntro2 =3D "This script will be opening and closing explorer =
windows in order to " & _
"apply the views. It is recommended you close other =
applications to run " & _
"this Script. To function properly, It is IMPERATIVE that you =
not have " & _
"any Explorer or I.E. windows open. If you have any open, =
please close " & _
"them before clicking 'OK'" & vbCrLf & vbCrLf & "Do you wish to =
continue?"
sSetView =3D "Alt+Tab to the Folder window now open and set all view =
options to your " & _
"liking. DO NOT CLOSE THE FOLDER YOURSELF! When you are done, =
Alt+Tab back to this window & click 'OK'."=20
End Sub


Re: Script for Folder View Customization - Beta by Brian

Brian
Sun Mar 13 01:29:50 CST 2005

Keith Miller wrote:
> I've rewritten the OpenAndCloseSubfolders function to handle 'access denied' issues:
> I've written this script to allow users to customize a view for a folder and then apply to all the subfolders. I thought I'd post it here first for comments and suggestions. It's not very robust with error handling :). It will hang if it runs into a folder with access denied. Can the gurus here take a look and help me tweak it before posting to the customize and music folk? I'm especially wondering about how to handle the timing in the OpenAndCloseSubfolders function. The loop I have now seems to be faster than using a sleep statement. I've left in a msgbox reporting execution time for the function which I plan to take out before the big rollout :)

I get the following message when I attempt to run the script. I'm not
sure what the problem is yet, but I'm going to start digging. I'm
running XP Home with SP2, WSH 5.6 - if that matters.

This line:

Set oAppShell = CreateObject("Shell.Application")

Generates this message:

---------------------------
Windows Script Host
---------------------------
Script: C:\Stuff\FolderViewSave.vbs
Line: 25
Char: 1
Error: ActiveX component can't create object
Code: 800A01AD
Source: Microsoft VBScript runtime error

---------------------------
OK
---------------------------

I don't know if it's:

1) Firewall and/or security settings,
2) Time to reinstall windows ;) , or
3) the fact that I'm running an alternate shell (not explorer.exe).

A quick google indicates that option 3 is the likely culprit. I suppose
I can log onto my boring old explorer account and see if it works there.
<sigh>

Re: Script for Folder View Customization - Beta by Brian

Brian
Sun Mar 13 01:53:18 CST 2005

And it was indeed the alternate shell that produced the error (there is
no explorer "Desktop", which is apparently required for the
shell.application object). The script ran fine when explorer was set as
the shell. Since this is an HKCU modification, I can't set up the
folders from the "explorer" user account; I have to set the shell back
to explorer, reboot, make the folder mods, then change back to my
preferred shell and reboot again, all using the same account. Bleh. Time
to research alternative implementations. Assuming it's possible at all,
your work ought to make it a whole lot easier though. =)

Re: Script for Folder View Customization - Beta by Keith

Keith
Sun Mar 13 02:59:37 CST 2005

If the only error was from accessing the Desktop, you could try =
modifying the code here -

Function RegExport (sRegPath, sFileName)
Dim sCmd, sTemp
sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
oScriptShell.Run sCmd, 0, True
RegExport =3D sTemp
End Function

that's the only place I reference the desktop, since I foolishly assumed =
everybody would have one :)

just change 'oScriptShell.SpecialFolders("Desktop")' to a path that =
exists under your shell.

Question:

1) What are you using for your shell?

Keith

"Brian Wolven" <brian.wolven@domain.invalid> wrote in message =
news:eNTw3G6JFHA.3992@TK2MSFTNGP15.phx.gbl...
> And it was indeed the alternate shell that produced the error (there =
is=20
> no explorer "Desktop", which is apparently required for the=20
> shell.application object). The script ran fine when explorer was set =
as=20
> the shell. Since this is an HKCU modification, I can't set up the=20
> folders from the "explorer" user account; I have to set the shell back =

> to explorer, reboot, make the folder mods, then change back to my=20
> preferred shell and reboot again, all using the same account. Bleh. =
Time=20
> to research alternative implementations. Assuming it's possible at =
all,=20
> your work ought to make it a whole lot easier though. =3D)

Re: Script for Folder View Customization - Beta by Keith

Keith
Sun Mar 13 03:18:56 CST 2005

Additional Question:

Where did the script error out in your alternate shell? Line # ? =
Column? Error# ?

Keith
"Keith Miller" <k.miller79@verizon.net> wrote in message =
news:%23vAd7r6JFHA.1040@TK2MSFTNGP10.phx.gbl...
If the only error was from accessing the Desktop, you could try =
modifying the code here -

Function RegExport (sRegPath, sFileName)
Dim sCmd, sTemp
sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
oScriptShell.Run sCmd, 0, True
RegExport =3D sTemp
End Function

that's the only place I reference the desktop, since I foolishly assumed =
everybody would have one :)

just change 'oScriptShell.SpecialFolders("Desktop")' to a path that =
exists under your shell.

Question:

1) What are you using for your shell?

Keith

"Brian Wolven" <brian.wolven@domain.invalid> wrote in message =
news:eNTw3G6JFHA.3992@TK2MSFTNGP15.phx.gbl...
> And it was indeed the alternate shell that produced the error (there =
is=20
> no explorer "Desktop", which is apparently required for the=20
> shell.application object). The script ran fine when explorer was set =
as=20
> the shell. Since this is an HKCU modification, I can't set up the=20
> folders from the "explorer" user account; I have to set the shell back =

> to explorer, reboot, make the folder mods, then change back to my=20
> preferred shell and reboot again, all using the same account. Bleh. =
Time=20
> to research alternative implementations. Assuming it's possible at =
all,=20
> your work ought to make it a whole lot easier though. =3D)

Re: Script for Folder View Customization - Beta by Brian

Brian
Sun Mar 13 13:30:29 CST 2005

Keith Miller wrote:
> If the only error was from accessing the Desktop, you could try modifying the code here -
>
> Function RegExport (sRegPath, sFileName)
> Dim sCmd, sTemp
> sTemp = oScriptShell.SpecialFolders("Desktop") & "\" & sFileName
> sCmd = "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & """"
> oScriptShell.Run sCmd, 0, True
> RegExport = sTemp
> End Function
>
> that's the only place I reference the desktop, since I foolishly assumed everybody would have one :)
>
> just change 'oScriptShell.SpecialFolders("Desktop")' to a path that exists under your shell.

The path exists - all the special folders are present, supported, and
known by CLSID. It's the creation of the shell.application object that
bombs. I assume it calls some DLL entry point in the shell executable,
and that function isn't supported (or its existence even known,
previously) by my alt shell.

> Question:
>
> 1) What are you using for your shell?

Litestep - http://en.wikipedia.org/wiki/LiteStep

Re: Script for Folder View Customization - Beta by Keith

Keith
Sun Mar 13 15:12:51 CST 2005

Hmmm....

Are you still using explorer to view folders?

If so, then I would guess views are still saved in the registry under:
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"

with the index to the bags under:
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"

There's nothing remarkable about my script, it's just that I discovered =
that if an 'AllFolders' subkey was in the Bags, it would be applied to =
any folder that did not already have a view saved.

I see there are scripting modules for litestep, so maybe if you take =
this info to their forums, someone there can write a script to do the =
following

1) delete "HKCU\...\BagMRU" and "HKCU\...\Bags"
2) open an explorer window to a particular folder - pause while the user =
sets the view options - close the window
3) create the key "HKCU\...\Bags\AllFolders" based on the info from the =
last number bag created
4) recursively open and then close all subfolders of the folder to save =
their new view
5) delete "HKCU\...\Bags\AllFolders"
6) goto 2

Good Luck,
Keith


"Brian Wolven" <brian.wolven@domain.invalid> wrote in message =
news:eSZ0cMAKFHA.2748@TK2MSFTNGP09.phx.gbl...
> Keith Miller wrote:
> > If the only error was from accessing the Desktop, you could try =
modifying the code here -
> >=20
> > Function RegExport (sRegPath, sFileName)
> > Dim sCmd, sTemp
> > sTemp =3D oScriptShell.SpecialFolders("Desktop") & "\" & =
sFileName
> > sCmd =3D "regedit.exe /A """ & sTemp & """ " & """" & sRegPath & =
""""
> > oScriptShell.Run sCmd, 0, True
> > RegExport =3D sTemp
> > End Function
> >=20
> > that's the only place I reference the desktop, since I foolishly =
assumed everybody would have one :)
> >=20
> > just change 'oScriptShell.SpecialFolders("Desktop")' to a path that =
exists under your shell.
>=20
> The path exists - all the special folders are present, supported, and=20
> known by CLSID. It's the creation of the shell.application object that =

> bombs. I assume it calls some DLL entry point in the shell executable, =

> and that function isn't supported (or its existence even known,=20
> previously) by my alt shell.
>=20
> > Question:
> >=20
> > 1) What are you using for your shell?
>=20
> Litestep - http://en.wikipedia.org/wiki/LiteStep

Re: Script for Folder View Customization - Beta by Brian

Brian
Sun Mar 13 18:59:03 CST 2005

Keith Miller wrote:
> Hmmm....
>
> Are you still using explorer to view folders?

Yep. Occasionally Xplorer2 or ExplorerXP, but 99% of the time it's plain
vanilla explorer.

> If so, then I would guess views are still saved in the registry under:
> "HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
>
> with the index to the bags under:
> "HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"

Yes to that, too. I have no problem running wsh scripts that modify the
registry - in general. There's just a specific problem that occurs owing
to the method in which your modifications are implemented. When (if?) I
have some free time, I'll see if there is a shell-independent workaround.

> There's nothing remarkable about my script, it's just that I discovered that if an 'AllFolders' subkey was in the Bags, it would be applied to any folder that did not already have a view saved.

Interesting discovery. Maybe I can put that to use in another way, by
*removing* view information from a set of folders and then tweaking the
allfolders view setting to match a certain style. This would effectively
change the views for the entire folder hierarchy, would it not -
assuming I deleted saved views for all such folders? Then another script
or two to switch between different allfolders views, and I'm good to go.
I only have three view types that get any use, generally. One for music
files, one for photos, and the other "Standard" view I use for all the
normal documents, source code, etc. I've already got mouse gestures or
hotkeys to do all my other window manipulation tasks, so this is the
"final frontier". =)

> I see there are scripting modules for litestep, so maybe if you take this info to their forums, someone there can write a script to do the following
>
> 1) delete "HKCU\...\BagMRU" and "HKCU\...\Bags"
> 2) open an explorer window to a particular folder - pause while the user sets the view options - close the window
> 3) create the key "HKCU\...\Bags\AllFolders" based on the info from the last number bag created
> 4) recursively open and then close all subfolders of the folder to save their new view
> 5) delete "HKCU\...\Bags\AllFolders"
> 6) goto 2

None of them are well suited for making registry modifications, I'm
afraid. For the most part, the shell's scripting modules are just used
to handle dynamic variables, toggling components on and off, modifying
their position or visibility, etc. I also use some of the shell
scripting in conjunction with a vbscript to parse XML weather feeds and
display the data on my desktop or in a popup menu. Scripting abilities
are one of the things that the developers will probably look to address
in future revisions. Since it's an open source effort, it all depends on
when they feel like it, when they get around to it, and who "they" are
at any moment in time. (Several ex-developers are now employed by
microsoft, BTW - shell coding is good training apparently!)

The shell installer makes some changes and additions to permit easy
swapping between the default explorer shell and Litestep, but that's an
EXE. If the scripting changes get too involved, or seem to be too slow,
I might consider asking someone to write a module (a supplementary DLL
loaded by the shell core) that would provide this capability. Maybe I'd
even try it myself - after additional research and some thorough
registry backups, of course!

Re: Script for Folder View Customization - Beta by Keith

Keith
Sun Mar 13 21:36:00 CST 2005


"Brian Wolven" <brian.wolven@domain.invalid> wrote in message =
news:%23$8ADEDKFHA.1476@TK2MSFTNGP09.phx.gbl...
> Keith Miller wrote:
> >=20
> > Are you still using explorer to view folders?
>=20
> Yep. Occasionally Xplorer2 or ExplorerXP, but 99% of the time it's =
plain=20
> vanilla explorer.
>=20
Ok, good

> > If so, then I would guess views are still saved in the registry =
under:
> > "HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
> >=20
>=20
> Yes to that, too. I have no problem running wsh scripts that modify =
the=20
> registry - in general. There's just a specific problem that occurs =
owing=20
> to the method in which your modifications are implemented. When (if?) =
I=20
> have some free time, I'll see if there is a shell-independent =
workaround.
>=20
> > There's nothing remarkable about my script, it's just that I =
discovered that if an >>'AllFolders' subkey was in the Bags, it would be =
applied to any folder that did not already >>have a view saved.
>=20
> Interesting discovery. Maybe I can put that to use in another way, by=20
> *removing* view information from a set of folders and then tweaking =
the=20
> allfolders view setting to match a certain style. This would =
effectively=20
> change the views for the entire folder hierarchy, would it not -=20
> assuming I deleted saved views for all such folders?=20

Yes, that's essentially what my script is doing...any folder opened that =
doesn't have a saved view ( and they're all deleted at the beginning) =
will use 'AllFolders'. =20
=20
>Then another script=20
> or two to switch between different allfolders views, and I'm good to =
go.=20
> I only have three view types that get any use, generally. One for =
music=20
> files, one for photos, and the other "Standard" view I use for all the =

> normal documents, source code, etc. I've already got mouse gestures or =

> hotkeys to do all my other window manipulation tasks, so this is the=20
> "final frontier". =3D)
>=20
> > I see there are scripting modules for litestep, so maybe if you take =
this info to their forums, someone there can write a script to do the =
following
> >=20
> > 1) delete "HKCU\...\BagMRU" and "HKCU\...\Bags"
> > 2) open an explorer window to a particular folder - pause while the =
user sets the view options - close the window
> > 3) create the key "HKCU\...\Bags\AllFolders" based on the info from =
the last number bag created
> > 4) recursively open and then close all subfolders of the folder to =
save their new view
> > 5) delete "HKCU\...\Bags\AllFolders"
> > 6) goto 2
>=20
> None of them are well suited for making registry modifications, I'm=20
> afraid.=20

My registry modications are all done using regedit.exe & text file =
manipulation -- can't any of the scripting modules do that?

>Maybe I'd=20
> even try it myself - after additional research and some thorough=20
> registry backups, of course!

That's the spirit!

I'm gonna see if I can do a quick mod to make it function w/o the =
application.shell object. I hope you can run vbscripts that use the =
file system object. The primary advantage to using application.shell =
was using the 'Browse for Folder' dialog and accessing the namespace =
folders. Should be no problem for folders such as "c:\docs & =
setting\user\My Docs" but "Desktop\My Docs" may be more of a problem.

Keith

Re: Script for Folder View Customization - Beta by Brian

Brian
Sun Mar 13 22:14:29 CST 2005

Keith Miller wrote:

>
> My registry modications are all done using regedit.exe & text file manipulation -- can't any of the scripting modules do that?
>

Yep, but vbcsript's capabilities are equal to or better than our
homegrown scripting modules in any category I can think of other than
internal shell-specific functions.

> I'm gonna see if I can do a quick mod to make it function w/o the
application.shell object. I hope you can run vbscripts that use the
file system object. The primary advantage to using application.shell
was using the 'Browse for Folder' dialog and accessing the namespace
folders. Should be no problem for folders such as "c:\docs &
setting\user\My Docs" but "Desktop\My Docs" may be more of a problem.

No problems there. I write the data I extract from the XML weather feeds
into text files that the shell can read, essentially a set of variable
definitions. I can use the MSxml2.DOMDocument.3.0 and xmlHTTP objects,
the file system object, SAPI.SpFileStream, SAPI.Voice, etc.

I also wrote a script that recurses a folder hierarchy and calls SAPI5
functions in order to generate synthetic voice clips that "speak" the
names of folders and certain types [configurable] of files. In
conjunction with yet another open source project (Rockbox - firmware for
Archos (and soon more!) mp3 players) this provides the ability to
navigate and select files and folders on the device without having to
see anything. Handy for me when I listen while driving (selecting songs,
playlists, etc.), and a bargain for members of the Blind community, who
typically have to pay through the nose in order to get portable devices
with speech synthesis capabilities. The developers incorporated speech
capability into all of the device menus/settings as well; only the
user's personal files need to be processed separately by the script (it
runs on a PC, but sees the device file system as a portable USB drive).

The only function I've ever run into that *didn't* work properly on
account of the shell I use is that shell.application object. Figures,
huh? =)

Re: Script for Folder View Customization - Beta by Keith

Keith
Mon Mar 14 03:02:36 CST 2005

This is a multi-part message in MIME format.

------=_NextPart_000_0B5F_01C52842.46590980
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


"Brian Wolven" <brian.wolven@domain.invalid> wrote in message =
news:uFJAQxEKFHA.1176@TK2MSFTNGP12.phx.gbl...

> The only function I've ever run into that *didn't* work properly on=20
> account of the shell I use is that shell.application object. Figures,=20
> huh? =3D)

Yep, but I think I've got a version here that works without =
shell.application, it's attached. It currently can only handle DOS type =
paths, not the namespace. I'll play with that after I get some sleep =
:-)

Keith
------=_NextPart_000_0B5F_01C52842.46590980
Content-Type: application/octet-stream;
name="FolderViewMaster_SansAppShell.vbs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="FolderViewMaster_SansAppShell.vbs"

'************************************************
' Folder ViewMaster *
' author: Keith Miller *
' =A9 Keith Miller :) *
'************************************************

Const conBagMRUPath =3D _
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU"
Const conBagsPath =3D _
"HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags"
Const conFolderStreams =3D _
=
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults=
\{F3364BA0-65B9-11CE-A9BA-00AA0=AD04AE837}"
Const ForReading =3D 1

dim oScriptShell, oFso, oFolder
dim VPathCollection ()
dim sIntroMsg, sScriptTitle, sIntro2, sSetView

'Instructions & Warnings
InitMsgStrs
If (msgbox(sIntroMsg, vbYesNo, sScriptTitle) <> vbYes) Then
WScript.Quit
End If
If (msgbox(sIntro2, vbYesNo + vbCritical, sScriptTitle) <> vbYes) Then
WScript.Quit
End If

'Assign objects
Set oScriptShell =3D CreateObject("WScript.Shell")=20
Set oFSO =3D CreateObject("Scripting.FileSystemObject")


'Back up the Registry Keys
Call RegExport(conBagMRUPath, "BagMRU Backup.reg")
Call RegExport(conBagsPath, "Bags Backup.reg")

DeleteBagsAndIncreaseLimit
'If conFolderStreams exists,it screws up the
' default columns for detail view of special folders. So...
On Error Resume Next
oScriptShell.RegDelete conFolderStreams
Err.Clear
On Error Goto 0

iNewBagCount =3D 0
bContinue =3D True
iLoopCount =3D 0

Do While bContinue '*** The Fun Starts Here ***
iLoopCount =3D iLoopCount + 1

sFolderPath =3D InputBox ("Type the full path of the folder you wish =
to modify")
scmd =3D "explorer.exe " & sFolderPath
oScriptShell.Run scmd
WScript.Sleep 2000

msgbox sSetView,,sFolderPath & " - Script Paused..."

oScriptShell.SendKeys "%{F4}"

iNewBagCount =3D iNewBagCount + 1

ReDim Preserve VPathCollection(iLoopCount - 1)
VPathCollection(iLoopCount - 1) =3D =
VPath(oFso.GetFolder(sFolderPath))
sFolderTemplateFile =3D MakeFolderTemplate(iNewBagCount)

RegImport sFolderTemplateFile

sStart =3D Now

iNewBagCount =3D iNewBagCount + OpenAndCloseSubfolders(sFolderPath)

MsgBox "Finished in " & DateDiff("s", sStart, Now) & " seconds", _=20
vbSystemModal, "OpenAndCloseSubfolders"


oFso.GetFile(sFolderTemplateFile).Delete
oScriptShell.RegDelete(conBagsPath & "\AllFolders\Shell\")
oScriptShell.RegDelete(conBagsPath & "\AllFolders\")

msg =3D "You have saved views for the following folder(s):" & vbCrLf
For each sPath in VPathCollection
msg =3D msg & vbTab & sPath & vbCrLf
Next
msg =3D msg & "You have saved views for " & iNewBagCount & " folders =
(8000 max)" & vbCrLf
msg =3D msg & vbCrLf & "Would you like to do another folder?"
bcontinue =3D msgbox (msg, vbYesNo) =3D vbYes
Loop

Set oAppShell =3D Nothing
Set oScriptShell =3D Nothing
Set oFSO =3D Nothing

'---------------------------------------End------------------------------=
-----

Function MakeFolderTemplate (iBagNum)
Dim sTemplateRegPath, sTemplateFileName, sFolderTemplate, ts
Dim sSearch, sReplace

sTemplateRegPath =3D conBagsPath & "\" & iBagNum
sTemplateFileName =3D "Folder Template" & iBagNum & ".reg"
sFolderTemplate =3D RegExport (sTemplateRegPath, sTemplateFileName)
'msgbox sFolderTemplate
Set ts =3D oFso.OpenTextFile(sFolderTemplate, ForReading)
sTemplateInfo =3D ts.ReadAll
ts.close

sSearch =3D "Bags\" & iNewBagCount
sReplace =3D "Bags\AllFolders"
sTemplateInfo =3D Replace (sTemplateInfo, sSearch, sReplace, 1, 2)
sTemplateInfo =3D Replace (sTemplateInfo, "My", "")

Set ts =3D oFso.CreateTextFile (sFolderTemplate, true)
ts.Write sTemplateInfo
ts.Close

Set ts =3D Nothing
MakeFolderTemplate =3D sFolderTemplate =20
End Function

'----------------------------------------

Function OpenAndCloseSubfolders (sFolderPath)
Dim iCount
Dim oFolder
iCount=3D0
For Each oFolder in oFso.GetFolder(sFolderPath).SubFolders
If NotZipped(oFolder) and NotAlreadySaved(oFolder) Then
iCount =3D iCount + OpenAndCloseSubfolders(oFolder.Path)
'**Check for folder access permission
On Error Resume Next
dummy =3D oFolder.size
If Err.Number <> 0 Then
Err.Clear
On Error Goto 0
Else
On Error Goto 0
=09
scmd =3D "explorer.exe " & oFolder.Path
oScriptShell.Run scmd
WScript.Sleep 1000
oScriptShell.SendKeys "%{F4}"
WScript.Sleep 1000
iCount =3D iCount + 1
End If
End If
Next
OpenAndCloseSubfolders =3D iCount
End Function

'-----------------------------------------

Sub DeleteBagsAndIncreaseLimit ()
Dim tFolder, tName, tFile, tString
Const TemporaryFolder =3D 2
Set tFolder =3D oFso.GetSpecialFolder(TemporaryFolder)

tName =3D oFso.GetTempName =20
Set tFile =3D tFolder.CreateTextFile(tName)
tString =3D _
"REGEDIT4" & vbCrLf & vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU]" =
& vbCrLf & _
"[-HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags]" & =
vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell]" & vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam]" & =
vbCrLf & _
"""BagMRU Size""=3Ddword:00001f40" & vbCrLf & vbCrLf & _
=
"[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Ex=
plorer]" & vbCrLf & _
"""NoSaveSettings""=3Ddword:00000000" & vbCrLf & vbCrLf
tFile.write (tString)
tFile.close
RegImport (tFolder.Path & "\" & tName)
oFso.GetFile(tFolder.Path & "\" & tName).Delete
End Sub =20

'-----------------------------------------

Sub RegImport (sFileName)
Dim sCmd
sCmd =3D "regedit.exe /s """ & sFileName & """&quo