i need help with a vbscript.
i'm a complete newbie.
i'm sitting on a Windows Server 2008 and i need a script that recursivly deletes folders, subfolders and files.
the folder is located in D:\Shared\temp
i just want to delete files and folders that are older than 24 hours old.
i don't want it to delete the Shared folder, only the contents of temp subfolder and its subfolders only if they are older than 24 hours.
i have come only this far:
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFiles fso.GetFolder("D:\Shared\temp")
Sub DeleteFiles(srcFolder)
Dim srcFile
If srcFolder.Files.Count = 0 Then
Wscript.Echo "No File to Delete"
Exit Sub
End If
For Each srcFile in srcFolder.Files
If DateDiff("h", Now, srcFile.DateCreated) < -24 Then
fso.DeleteFile srcFile, True
End If
Next
Wscript.Echo "Files Deleted successful"
End Sub
I don't think that the current script deletes folder,subfolders or files unless they are 0 Bytes
if it isn't too much trouble can you eplain where the recursion starts and ends
P.s. Where can i schedule the task/script that it runs at 1:30 am?
Thanks a bunch
i'm a complete newbie.
i'm sitting on a Windows Server 2008 and i need a script that recursivly deletes folders, subfolders and files.
the folder is located in D:\Shared\temp
i just want to delete files and folders that are older than 24 hours old.
i don't want it to delete the Shared folder, only the contents of temp subfolder and its subfolders only if they are older than 24 hours.
i have come only this far:
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFiles fso.GetFolder("D:\Shared\temp")
Sub DeleteFiles(srcFolder)
Dim srcFile
If srcFolder.Files.Count = 0 Then
Wscript.Echo "No File to Delete"
Exit Sub
End If
For Each srcFile in srcFolder.Files
If DateDiff("h", Now, srcFile.DateCreated) < -24 Then
fso.DeleteFile srcFile, True
End If
Next
Wscript.Echo "Files Deleted successful"
End Sub
I don't think that the current script deletes folder,subfolders or files unless they are 0 Bytes
if it isn't too much trouble can you eplain where the recursion starts and ends
P.s. Where can i schedule the task/script that it runs at 1:30 am?
Thanks a bunch