………………VBS脚本问题………………

来源:百度知道 编辑:UC知道 时间:2024/06/15 14:21:51
检测指定目录下是否存在指定后缀的文件,如:(D:\测试目录)下是否存在后缀为.xyz的文件,如果存在,则2分钟后再次检测;如果不存在,则弹出提示框。
验证有效后给分!
.
额,不需要列举出来,只要判断出来指定后缀的文件是否存在,存在则2分钟后再次检测;不存在则提示。

Set FSO=CreateObject("Scripting.FileSystemObject")
Set f=FSO.GetFolder(InputBox("请指定目录!","hkmfk","C:\Windows"))
for each i in f.files
if FSO.GetExtensionName(i) = "ini" then MsgBox i.name &vblf &i
next

直接点确定,找出Windows目录下的ini文件!试一下
oh my god 思路都出来了改一下下不行啊!

Set FSO=CreateObject("Scripting.FileSystemObject")
Dim filecount,folpath
folpath=InputBox("请指定目录!","hkmfk","C:\")
ext=lcase(InputBox("请指定扩展名!","hkmfk","txt"))
while true
reDim preFile(0)
Set f=FSO.GetFolder(folpath)
for each i in f.files
if lcase(FSO.GetExtensionName(i)) = ext then
filecount =ubound(preFile)
preFile(filecount)= i.name
ReDim Preserve preFile(filecount+1)
end if
next
if preFile(0)<> "" then
msgbox "共发现" & ext & "