我正在寫一個VBScript for SyncBack(備份工具),我正在刪除舊版本的備份。如何刪除文件夾時暫停VBS腳本?
'' # if current version is greater than the total allowed number of versions,
'' # delete the oldest folder
If versionNumber > totalVersions Then
delDirNum = versionNumber - totalVersions
If delDirNum > 0 Then
DelFoldername = containerFileOrFolder & "\" & delDirNum & "_"
'' " # Ignore this line SO Prettify doesn't do VB very well.
If fso.FolderExists(DelFoldername) = True Then
WScript.Echo "Deleting: <" & DelFoldername & ">"
Set oFolder = objFileSystem.GetFolder(DelFoldername)
oFolder.Delete()
WScript.Sleep 2000
If fso.FolderExists(DelFoldername) = False Then
WScript.Echo "Deleted <" & DelFoldername & "> successfully"
Else
WScript.Echo "Could not delete <" & DelFoldername & ">"
End If
End If
End If
End If
但是,偶爾的文件夾(包含舊的備份),這我試圖刪除需要更長的時間是2秒WScript.Sleep 2000刪除,我想知道是否有一種方式在打印出「刪除<文件夾名稱>成功」之前,使腳本等到文件夾被刪除。
理想我很樂意這樣的:
While oFolder.IsDeleting() Then
WScript.Echo "Still deleting..."
WScript.Sleep 2000
Loop
但我清楚地知道,這可能不會是這樣。
什麼objFileSystem的類型? – 2009-11-20 13:02:19
FileSystemObject:http://msdn.microsoft.com/en-us/library/z9ty6h50(VS.85).aspx – 2009-11-20 13:08:03