当我运行脚本时,我收到错误,我无法理解为什么。 错误是:
d:\ learning \ vbs \ backup3.vbs(32,1)
运行时错误Microsoft VBScript:找不到路径。
此字符串出错:Set objFolder = objFSO.GetFolder(str)
我的代码:
Option Explicit
Dim objFSO
Dim objShell
Dim objFolder
Dim sourceDir
Dim destDir
Dim rar
Dim n
sourceDir = "d:\learning\vbs\TBack"
destDir = "\\LILO\Users\monorels\Music\Backup"
rar = "d:\learning\vbs\Rar.exe"
n = 3
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run """rar"" a -agYYYY-MM-DD-HH-MM-SS " & destDir & " " & sourceDir
search_delete "\\LILO\Users\monorels\Music\Backup", n
Sub search_delete(str, n)
Dim strOldestFile, dtmOldestDate
Dim count
Dim intFolderSize
Dim objFolder
Dim colFiles
Dim strFile
Dim delFile
Dim fso
strOldestFile = ""
dtmOldestDate = Now
Set objFolder = objFSO.GetFolder(str)
Set colFiles = objFolder.Files
Do
count = 0
For Each objFile In colFiles
count = count + 1
strFile = objFile.Path
dtmFileDate = objFile.DateCreated
If dtmFileDate < dtmOldestDate Then
dtmOldestDate = dtmFileDate
strOldestFile = strFile
End If
Next
objFSO.DeleteFile (strOldestFile)
Loop Until count > n
End Sub
请帮帮我。