如何使用VBScript删除临时文件夹中以特定名称开头的所有文件
我正在尝试使用下面的VB脚本从Windows临时文件夹中删除所有以字符串“MyApp”开头的日志文件如何使用VBScript删除临时文件夹中以特定名称开头的所有文件,vbscript,Vbscript,我正在尝试使用下面的VB脚本从Windows临时文件夹中删除所有以字符串“MyApp”开头的日志文件 Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") if objFSO.FolderExists("C:\Documents and Settings\guest\MyApp") Then set folder = objFSO.getFolder("C:\Documents and Sett
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
我认为VBScript不支持使用通配符的FileExists。更好的选择是抑制delete中的错误并运行DeleteFile命令
On error resume next
objFSO.DeleteFile "C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*", True
最好将此作为答案发布,否则人们会继续打开此页面以help@peter-我如何将此作为答案发布。就像您回答其他人的问题一样,填写下面的编辑器并单击“发布您的答案”,您是否需要等待一天才能发布答案
On error resume next
objFSO.DeleteFile "C:\Documents and Settings\guest\Local Settings\Temp\MyApp.*", True