我編寫了一個腳本來抓取文件中的文件夾列表,它將檢查並刪除超過90天的文件。vbs(25,3)Microsoft VBScript運行時錯誤:無效的過程調用或參數
該腳本能夠刪除超過90天的文件。然而,我繼續得到一個錯誤說:
D:\cleanup90days.vbs(25, 3) Microsoft VBScript runtime error: Invalid procedure call or argument
我不知道我錯過了什麼。任何幫助將不勝感激。
下面是我的腳本:
Dim days
Dim inputFolderList, ObjFolder, Files, objFileAge
If Not WScript.Arguments.Count = 2 Then
Wscript.Echo "Invalid number of arguments. Arg1: Daily or Weekly. Arg2: Remove all files older then this"
WScript.Quit(-1)
End If
days = WScript.Arguments.Item(1)
inputFileList = "D:\FileGrep2.txt"
Set Fso = CreateObject("Scripting.FileSystemObject")
Set objTextFile = fso.OpenTextFile(inputFileList, 1)
Do Until objTextFile.AtEndOfStream
sFolderName = objTextFile.ReadLine
getfoldernames(sFolderName)
Loop
Function getfoldernames(sFolderName)
Set ObjFolder = fso.GetFolder(sFolderName)
Set Files = ObjFolder.Files
For Each Check In Files
objFileAge = DateDiff("n", Check.DateLastModified, Now)
If objFileAge > 90 Then
WScript.Echo Now & "the following will be deleted " & Check.Path
Check.Delete
End If
Next
End Function
您的腳本看起來沒問題......腳本中還有其他事情嗎?或者這是完整的腳本? –
在調用'getfoldernames(sFolderName)之前檢查'sFolderName'是否爲空' – SearchAndResQ
您發佈的代碼中的第25行是'objFileAge = DateDiff(「n」,Check.DateLastModified,Now)'。這真的是提高錯誤的路線嗎? –