IE9 Windows7 (64 ビット) でキャッシュをクリアするスクリプトを作成しようとしています。これまでのところ、以下のコードを書いています。このコードは IE8 と Windows XP では問題なく動作しますが、同じコードを WINdows7 (IE9) で実行しようとすると、「Permission denied Line (39): "fso.DeleteFile (strWinFolder & "\Temp*. " ), True : fso.DeleteFolder (strWinFolder & "\Temp*. "), True"."
スクリプトを確認して、間違っているところを修正してください。どこか間違っていたらすみません。
Dim methodName, fso, WshNetwork, WshShell, strVer, OSver, strWinFolder, strTempFolder, GetOS, strProfile, WindowsFolder, TemporaryFolder, NewFolder
Set fso = CreateObject("Scripting.FileSystemObject") : Set WshNetwork = CreateObject("Wscript.Network")
set WshShell = createobject("wscript.shell") : set strVer = WshShell.exec("cmd /c ver")
OSver = strVer.stdout.readall
If InStr(OSver, "XP") Then GetOS = "WXP" : If InStr(OSver, "2000") Then GetOS = "W2K"
If InStr(OSver, "NT") Then GetOS = "NT4" : If InStr(OSver, "98") Then GetOS = "W98"
If InStr(OSver, "Millennium") Then GetOS = "W98"
strWinFolder = fso.GetSpecialFolder(WindowsFolder)
'strTempFolder = fso.GetSpecialFolder(TemporaryFolder)
If GetOS = "WXP" OR GetOS = "W2K" Then
Flag1 = True
strProfile = "c:\Documents and Settings\"
Else
Flag1 = False
End If
If GetOS = "NT4" Then
Flag2 = True
strProfile = "c:\winnt\profiles\"
Else
Flag2 = False
End If
If Flag1 = False and Flag2 = False Then
GetOS = "W7"
Flag3 = True
strProfile = "C:\Users\"
Else
Flag3 = False
End If
'Delete the Temp files in the C:\Users folder.
If fso.FolderExists(strWinFolder & "\Temp\") Then
fso.DeleteFile (strWinFolder & "\Temp\*.*"), True : fso.DeleteFolder (strWinFolder & "\Temp\*.*"), True
End If
If Not fso.FolderExists(strWinFolder & "\Temp\") Then NewFolder = fso.CreateFolder (strWinFolder & "\Temp\") End If
If Flag1 = True And Flag2 = True Then
'Delete the recently viewed document links in the C:\Documents and Settings\"USERNAME"\Recent folder.
If fso.FolderExists(strProfile & WshNetwork.username & "\Recent\") Then fso.DeleteFile (strProfile & WshNetwork.username & "\Recent\*.*"), True End If
'Delete the Temp files in the C:\Documents and Settings\"USERNAME"\Local Settings\Temp folder.
If fso.FolderExists(strProfile & WshNetwork.username & "\Local Settings\Temp\") Then
'fso.DeleteFile (strProfile & WshNetwork.username & "\Local Settings\Temp\*.*"), True
'fso.DeleteFolder (strProfile & WshNetwork.username & "\Local Settings\Temp\*.*"), True
End If
'Delete the Temporary Internet files and folders in the C:\Documents and Settings\"USERNAME"\Local Settings\Temporary Internet Files folder.
'wshShell.run "cmd /c del " & strprofile & WshNetwork.Username & "\Tempor~1\*.* /q", 1, True
'fso.DeleteFile (strProfile & WshNetwork.username & "\Tempor~1\*.*"), True
If fso.FolderExists(strProfile & WshNetwork.username & "\Local Settings\Temporary Internet Files\") Then
fso.DeleteFile (strProfile & WshNetwork.username & "\Local Settings\Temporary Internet Files\*.*"), True
'fso.DeleteFile (strProfile & WshNetwork.username & "\Local Settings\Temporary Internet Files\Content.IE5\*.*"), True
End If
End If
If Flag3 = True Then
'Delete the Recent files on WIndows7 C:\Users\AA24800\AppData\Roaming\Microsoft\Windows\Recent
If fso.FolderExists(strProfile & WshNetwork.username & "\AppData\Roaming\Microsoft\Windows\Recent") Then
fso.DeleteFile (strProfile & WshNetwork.username & "\AppData\Roaming\Microsoft\Windows\Recent\*.*"), True
End If
'Delete Temporary Internet Files on WIndows7
If fso.FolderExists(strProfile & WshNetwork.username & "\AppData\Local\Microsoft\Windows\Temporary Internet Files") Then
fso.DeleteFile (strProfile & WshNetwork.username & "\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*"), True
End If
End If
set fso = Nothing : set wshshell = Nothing : set WshNetwork = Nothing : set NewFolder = Nothing