Board logo

标题: VBS查找并打开文件的代码,请高手帮我修改一下 [打印本页]

作者: 5872169     时间: 2009-3-4 03:04    标题: VBS查找并打开文件的代码,请高手帮我修改一下

VBS查找并打开文件的代码,请高手帮我修改一下,搜索到文件后,点是用D:\Kmplayer Plus\KMPlayer.exe打开,点否继续搜索,点取消退出程序
Function FilesTree(sPath)   
Set oFso=CreateObject("Scripting.FileSystemObject")   
Set oFolder=oFso.GetFolder(sPath)   
Set oSubFolders=oFolder.SubFolders   
   
Set oFiles=oFolder.Files   
For Each oFile In oFiles   
MSGBOX oFile.Path,vbQuestion+vbYesNoCancel,"打开"

createobject("wscript.shell").run chr(34)&"D:\Kmplayer Plus\KMPlayer.exe"&chr(34) & (oFile.Path)

Next  
   
For Each oSubFolder In oSubFolders   
MSGBOX oSubFolder.Path,vbQuestion+vbYesNoCancel,"打开"
FilesTree(oSubFolder.Path)'递归   
Next  
   
Set oFolder=Nothing  
Set oSubFolders=Nothing  
Set oFso=Nothing  
End Function  
  
FilesTree("E:\电影") '遍历
作者: qinchun36     时间: 2009-3-4 13:19

Function FilesTree(sPath)
Set oFso=CreateObject("Scripting.FileSystemObject")
Set oFolder=oFso.GetFolder(sPath)
Set oSubFolders=oFolder.SubFolders
Set oShell=CreateObject("Wscript.Shell")
   
Set oFiles=oFolder.Files
For Each oFile In oFiles
Select case MSGBOX(oFile.Path,35,"打开")
case 6 oShell.run chr(34)&"D:\Kmplayer Plus\KMPlayer.exe"&chr(34)&" "&chr(34)&oFile.Path&chr(34)
case 2 wscript.quit
end select
Next
   
For Each oSubFolder In oSubFolders
FilesTree(oSubFolder.Path)'递归
Next
   
Set oFolder=Nothing
Set oSubFolders=Nothing
Set oFso=Nothing
End Function
  
FilesTree("E:\电影") '遍历
[ Last edited by qinchun36 on 2009-3-6 at 01:44 ]