フォルダの表示設定の保存場所はどこか?
各フォルダの表示形式、カラム、ソートなどは、以下のレジストリに保存されていますが、
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\数字\Shell\{フォルダタイプ}
この数字、{フォルダタイプ}とフォルダの対応が取れないとどうしようもありません。
そこで、フォルダをWhereIsFolderSettings.vbsにドロップします。
フォルダパス名を省略すると、開いているフォルダの中から選択します。
保存場所が見つかると、その場所(レジストリキー)と適用されているフォルダタイプの名前を表示します。
WhereIsFolderSettings.vbs [フォルダパス名]
Option Explicit
Const HKCU=&H80000001
Dim Path
Dim ie
Dim Shell
Dim wShell
Dim Modes
Dim SubKeys
Dim oReg
Dim k,j
Dim SubSubKeys
Dim Mode
Dim SubKey
Dim CurrentViewMode
If WScript.Arguments.Count Then
Path=WScript.Arguments.Item(0)
Set ie=GetObject("new:{C08AFD90-F2A1-11D1-8455-00A0C91F3880}")
' ie.Visible=True
ie.Navigate Path
Do While ie.Busy Or ie.ReadyState<>4
WScript.Sleep 100
Loop
Else
Set Shell=CreateObject("Shell.Application")
For Each ie In Shell.Windows
If InStr(LCase(ie.FullName),"explorer.exe") Then
If MsgBox(ie.LocationURL,1,"Which folder to get ID of ?")=1 Then Exit For
End If
Next
If IsEmpty(ie) Then WScript.Quit
End If
Set wShell=CreateObject("WScript.Shell")
Set Modes=CreateObject("Scripting.Dictionary")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.EnumKey HKCU,"Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\",SubKeys
For k=0 To UBound(SubKeys)
oReg.EnumKey HKCU,"Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\" & SubKeys(k) & "\Shell\",SubSubKeys
If IsArray(SubSubKeys) Then
For j=0 To UBound(SubSubKeys)
Mode=RegRead("HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\" & SubKeys(k) & "\Shell\" & SubSubKeys(j) & "\Mode")
If Mode Then Modes.Add SubKeys(k) & "\Shell\" & SubSubKeys(j),Mode
Next
End If
Next
CurrentViewMode=ie.Document.CurrentViewMode
ie.Document.CurrentViewMode=CLng(CurrentViewMode) mod 2 +3
ie.Refresh
For Each SubKey In Modes
Mode=RegRead("HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\" & SubKey & "\Mode")
If Mode Then If Modes(SubKey)<>Mode Then WScript.Echo Join(Array("HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\" & SubKey,RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderTypes\"& Split(SubKey,"\")(2) & "\CanonicalName")),vbLf)
Next
ie.Document.CurrentViewMode=CurrentViewMode
If WScript.Arguments.Count Then
ie.Quit
Else
ie.Refresh
End If
Function RegRead(Key)
On Error Resume Next
RegRead=wShell.RegRead(Key)
End Function
« スクリプトでcsvファイルを整形する。(その3) | トップページ | バッチファイルでフォルダの詳細表示相当を保存印刷する。 »