>74行目 「見つかりませんでした」 80041002
ごめんなさい。
wmiのSINKはやめます
ではこれはどうでしょう?
お手数ですが、これを実行する前に、
一度フォルダオプションで「全フォルダのリセット」を
して
『マイドキュメント』、『マイコンピュータ』の
フォルダ設定をしておいてください。
const HKCU = &H80000001
const REG_SZ = 1
const REG_EXPAND_SZ = 2
const REG_BINARY = 3
const REG_DWORD = 4
const REG_MULTI_SZ = 7
dim StatusChk()
dim arrSubKeys
dim flag
Dim objTarget
dim FldrPath(100)
dim BackUpFile
dim ItmNo(100)
dim FolderCnt
BackUpFile = "FolderSetting_BackupFile.ini"
Set WshShell = WScript.CreateObject("WScript.Shell")
i = WshShell.PopUp("フォルダ設定をバックアップします" ,0,"ittochan",65)
if i<>1 then
WScript.Echo "中止しました"
WScript.Quit
end if
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(WScript.ScriptFullName)
BackUpFile = f.ParentFolder & "\" & BackUpFile
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strBags="Software\Microsoft\Windows\ShellNoRoam\Bags\"
flag=0
set Shell = WScript.CreateObject("Shell.Application")
set WindowsShell = Shell.Windows
getfldr()
if FolderCnt>0 then
for i=0 to FolderCnt-1
closefldr()
next
end if
openfolder "shell:Personal"
openfolder "shell:DriveFolder"
getfldr()
Set MyFile = fso.CreateTextFile(BackUpFile, True)
MyFile.WriteLine 2
MyFile.WriteLine "shell:Personal"
MyFile.WriteLine "shell:DriveFolder"
GetSubKey()
ReDim StatusChk(UBound(arrSubKeys))
for k=0 to FolderCnt-1
Set objTarget = WindowsShell.item(ItmNo(k))
'Bagsキーからアドレスバーの状態を取得します。
on error resume next
for i=0 to UBound(arrSubKeys)
inta = WshShell.RegRead("HKCU\" & strBags & arrSubKeys(i) & "\Shell\Address")
if Err.Number<>0 then
StatusChk(i) = 2
Err.Clear
else
StatusChk(i) = inta
end if
next
on error goto 0
'アドレスバーの設定を反転させる
AddressBarChange()
WScript.Sleep 1000
objTarget.Navigate FldrPath(k)
'アドレスバーの設定が元に戻った場所を探す
on error resume next
do
for i=0 to UBound(arrSubKeys)
inta = WshShell.RegRead("HKCU\" & strBags & arrSubKeys(i) & "\Shell\Address")
if Err.Number<>0 then
inta = 2
Err.Clear
end if
if StatusChk(i) <> inta then
BagNo = arrSubKeys(i)
Exit Do
end if
next
loop while 1
on error goto 0
'アドレスバーの設定を元に戻す
AddressBarChange()
strKeyPath = strBags & BagNo & "\Shell"
oReg.EnumValues HKCU, strKeyPath, arrValueNames, arrValueTypes
MyFile.WriteLine UBound(arrValueNames)
For i=0 To UBound(arrValueNames)
strv = arrValueNames(i)
MyFile.WriteLine arrValueTypes(i)
MyFile.WriteLine strv
strKeyPath1 = "HKCU\" & strKeyPath & "\" & strv
Select Case arrValueTypes(i)
Case REG_SZ
MyFile.WriteLine WshShell.RegRead( strKeyPath1 )
Case REG_EXPAND_SZ
MyFile.WriteLine WshShell.RegRead( strKeyPath1 )
Case REG_BINARY
oReg.GetBinaryValue HKCU,strKeyPath ,strv,strValue
MyFile.WriteLine uBound(strValue)
For j = 0 to uBound(strValue)
MyFile.WriteLine strValue(j)
Next
Case REG_DWORD
MyFile.WriteLine WshShell.RegRead( strKeyPath1 )
Case REG_MULTI_SZ
End Select
Next
next
getfldr()
for i=0 to FolderCnt-1
closefldr()
next
msgbox "終了しました"
MyFile.Close
WScript.Quit
sub getfldr()
dim i,j,k,obj
j=0
for i=0 to WindowsShell.Count-1
Set obj = WindowsShell.item(i)
if TypeName(obj)<>"Nothing" then
if InStr(obj.LocationURL,"file:///") = 1 then
ItmNo(j) = i
FldrPath(j) = obj.LocationURL
j=j+1
end if
end if
next
FolderCnt = j
end sub
sub closefldr()
dim i,obj
for i=0 to WindowsShell.Count-1
Set obj = WindowsShell.Item(i)
if TypeName(obj)<>"Nothing" then
if InStr(obj.LocationURL,"file:///")=1 then
pCnt = WindowsShell.Count
BusyCheck(obj)
obj.Quit
do while pCnt = WindowsShell.Count
WScript.Sleep 100
loop
Exit for
end if
end if
next
end sub
sub GetSubKey()
oReg.EnumKey HKCU, strBags, arrSubKeys
end sub
sub openfolder(path)
pCnt = WindowsShell.Count
Shell.Open path
do while pCnt = WindowsShell.Count
WScript.Sleep 100
loop
end sub
Sub AddressBarChange()
dim i
for i=0 to UBound(arrSubKeys)
if StatusChk(i)<>2 then
StatusChk(i) = not StatusChk(i)
WshShell.RegWrite "HKCU\" & strBags & arrSubKeys(i) & "\Shell\Address" ,StatusChk(i),"REG_DWORD"
end if
next
End sub
sub BusyCheck(obj)
do
WScript.Sleep 100
loop while obj.Busy
end sub
お礼
返事が遅くなりました。 完璧ですね。 うまくいきました。 ありがとうございました。
補足
↓のお礼の補足です。 いろいろお手数をおかけしました。 本当に助かりました。