עזרה ב vbscript - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

עזרה ב vbscript


bigblue

Recommended Posts

שלום לכולם יש לי vbscript שמוחק כל יום קבצים ישנים (קבצים שלא עברו שינוי 7 ימים)

הבעיה היא שלאחר שבע ימים גם קובץ הvbscript נמחק בעצמו.. מה עושים??

'First, you will need to setup a scheduled task and run it

'daily. Just change the number to the amount of days you

'want to keep file in that directory. Any files in the

'directory will be deleted. This file must be place WITHIN

'the directory you wish to clean.

'Courtesty of monsterjta @ tek-tips.com

'Start

'Delete any file in current directory that is older than iDaysOld

Option Explicit

on error resume next

Dim oFSO

Dim sDirectoryPath

Dim oFolder

Dim oFileCollection

Dim oFile

Dim iDaysOld

Dim CurDir

'Definitions

iDaysOld = 7

Set oFSO = CreateObject("Scripting.FileSystemObject")

sDirectoryPath = CreateObject("WScript.Shell").CurrentDirectory

sDirectoryPath = sDirectory & "\"

set oFolder = oFSO.GetFolder(sDirectoryPath)

set oFileCollection = oFolder.Files

'Walk through each file in this folder collection.

For each oFile in oFileCollection

If oFile.DateLastModified < (Date() - iDaysOld) Then

oFile.Delete(True)

End If

Next

'Clean up

Set oFSO = Nothing

Set oFolder = Nothing

Set oFileCollection = Nothing

Set oFile = Nothing

'End

קישור לתוכן
שתף באתרים אחרים

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...