Hi,
I want to write a script that returns an integer with the amount of files on my pc whose creation date is older then 60 days. Heres what I came up with so far:
now the problem is, when I set sroot to C:\ i get an error message from the wsh "access denied" . If I set sroot to C: then it runs, but as a return I get 0. If I set sroot to c:\windows for example, then the counter variable is about 2700, so I assume it works to a certain degree. Could someone please tell me what I did wrong?
I want to write a script that returns an integer with the amount of files on my pc whose creation date is older then 60 days. Heres what I came up with so far:
Code:
Dim fso
set fso = CreateObject("Scripting.FileSystemObject")
Dim counter
counter = 0
sroot = "C:\"
for each ofolder in fso.getfolder(sroot).subfolders
call deleteFile(ofolder)
next
msgbox(counter)
Public function deleteFile(Fld)
Set Fls = Fld.Files
for Each oFile in Fls
if oFile.DateCreated < date - 60 then
'MsgBox(oFile)
counter = counter + 1
end if
next
end function
now the problem is, when I set sroot to C:\ i get an error message from the wsh "access denied" . If I set sroot to C: then it runs, but as a return I get 0. If I set sroot to c:\windows for example, then the counter variable is about 2700, so I assume it works to a certain degree. Could someone please tell me what I did wrong?