2
我試圖使用以下VB腳本從Windows Temp文件夾中刪除以字符串「MyApp」開頭的所有日誌文件。如何刪除使用VBScript在臨時文件夾中以特定名稱開頭的所有文件
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FolderExists("C:\Documents and Settings\guest\MyApp") Then
set folder = objFSO.getFolder("C:\Documents and Settings\guest\MyApp")
if folder.files.Count <> 0 then
objFSO.DeleteFile "C:\Documents and Settings\guest\MyApp\*.*", True
end if
objFSO.DeleteFolder "C:\Documents and Settings\guest\MyApp", True
end if
<!-- The below code is not deleting the files which starts with the name "Mpp.023648011.log" -->
if(objFSO.FileExists("C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*")) Then
objFSO.DeleteFile "C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*", True
end if
看來下面檢查失敗:
如果(objFSO.FileExists( 「C:\ Documents和Settings \客\本地設置的\ Temp \ MyApp的*」))
提前致謝。
我找到了一種抑制錯誤信息並執行DeleteFile的方法。它爲我工作。
On error resume next
objFSO.DeleteFile "C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*", True
最佳發佈此作爲回答,否則人們不斷以幫助 – peter 2012-08-01 14:59:57
@peter打開此網頁 - 我怎樣才能發佈此作爲答案。 – JChan 2012-08-02 19:36:59
像你回答其他人的問題,填寫下面的編輯,然後單擊「發佈你的答案」,可能是你必須等待一天,所以纔可以 – peter 2012-08-02 20:05:08