Set netObj = WScript.CreateObject("WScript.Network")
Set fso = wscript.CreateObject("Scripting.FileSystemObject")
TempIntFilePath = "c:\documents and settings\"+netobj.UserName + "\Local
Settings\Temporary Internet Files\*.*"
TempWinntPath = "c:\documents and settings\"+netobj.UserName + "\Local
Settings\temp\*.*"
Temp2Path = "c:\winnt\temp\*.*"
TempIntFilePath = ucase(tempintfilepath)
WinntTempPath = ucase(TempWinntPath)
Temp2Path = ucase (Temp2Path)
fso.DeleteFile TempIntFilePath, true
fso.DeleteFile TempWinntPath, true
fso.DeleteFile Temp2Path, true
I keep getting permission denied. being run on windows 2000, sp 3 under an
admin account.
thanks
> Can anyone tell me why this code is not working:
> Set netObj = WScript.CreateObject("WScript.Network")
> Set fso = wscript.CreateObject("Scripting.FileSystemObject")
>
> TempIntFilePath = "c:\documents and settings\"+netobj.UserName + "\Local
> Settings\Temporary Internet Files\*.*"
> ...
> fso.DeleteFile TempIntFilePath, true
> ...
> I keep getting permission denied. being run on windows 2000, sp 3 under an
> admin account.
Temporary Internet Files are protected (not by r-Attribute).
Delete these Files from another user-account with admin rights
or by the IE-Deletion-Routine (which will leave half of the
TIFs)
mfg
Christoph
"Matt Pollicove" <matt...@optonline.net> wrote in message
news:OyIY6luaCHA.1744@tkmsftngp11...
thanks
"Joe Fawcett" <joefa...@hotmail.com> wrote in message
news:OFOUT6uaCHA.2588@tkmsftngp12...
> Do you have some sample code in this regard or know where I can get it?
Hi
Here is a Michael Harris script that deletes files older than x days using the
filesystemobject. You set the folder the script starts looking in, and the value
of the bIncludeSubFolders parameter tells it to include subfolders or not.
It handles locked files.
' folder to start search in...
path = "c:\temp"
' delete files older than 7 days...
killdate = date() - 7
arFiles = Array()
set fso = createobject("scripting.filesystemobject")
' Don't do the delete while you still are looping through a
' file collection returned from the File System Object (FSO).
' The collection may get mixed up.
' Create an array of the file objects to avoid this.
'
SelectFiles path, killdate, arFiles, true
nDeleted = 0
for n = 0 to ubound(arFiles)
'=================================================
' Files deleted via FSO methods do *NOT* go to the recycle bin!!!
'=================================================
on error resume next 'in case of 'in use' files...
arFiles(n).delete true
if err.number <> 0 then
wscript.echo "Unable to delete: " & arFiles(n).path
else
nDeleted = nDeleted + 1
end if
on error goto 0
next
msgbox nDeleted & " of " & ubound(arFiles)+1 _
& " eligible files were deleted"
sub SelectFiles(sPath,vKillDate,arFilesToKill,bIncludeSubFolders)
on error resume next
'select files to delete and add to array...
'
set folder = fso.getfolder(sPath)
set files = folder.files
for each file in files
' uses error trapping around access to the
' Date property just to be safe
'
dtlastmodified = null
on error resume Next
dtlastmodified = file.datelastmodified
on error goto 0
if not isnull(dtlastmodified) Then
if dtlastmodified < vKillDate then
count = ubound(arFilesToKill) + 1
redim preserve arFilesToKill(count)
set arFilesToKill(count) = file
end if
end if
next
if bIncludeSubFolders then
for each fldr in folder.subfolders
SelectFiles fldr.path,vKillDate,arFilesToKill,true
next
end if
end sub
--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway
can you please explain, "why is that when i delete files this way"
they are still visible in explorer..... it appears that the files *Have Not*
been deleted which causes me to pull hair out..
when i want to delete a file, *That's What I Mean* delete it from my
system, gone, adios, asta_la_Vista, bye bye..
i have WSH 5.6
Win 98 (Final)
David
If you look at the code, all errors for failed deletes are trapped and reported in order to not be stopped by files in use. There could be other reasons such real access denied due to permissions, but that is the exception rather than the rule. Files that don't delete using that script are generally those that are in use. Make sure there are no open browser instances when you run the script to minimize that chance.
--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
> David wrote:
> >
> > i have WSH 5.6
> > Win 98 (Final)
> >
>
> If you look at the code, all errors for failed deletes are trapped and reported in order to not be stopped by files in use. There could be other reasons such real access denied due to permissions, but that is the exception rather than the rule.
Especially on Win 98 ;-)