פורסם 2008 ביוני 1517 שנים שלום לכולם יש לי 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 iDaysOldOption Expliciton 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
פורסם 2008 ביוני 1517 שנים תוסיף לקובץ תנאי שישווה את שם הקובץ הנוכחי (oFile) לשם הקובץ של הסקריפט - WScript.ScriptFullName.אגב, להבא, תעטוף את הקוד שלך בטג קוד (כפתור # למעלה).
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.