- Dim ws
- Set ws = CreateObject("WScript.Shell")
-
- If WSH.Arguments.Count = 0 Then
- ws.Run "cscript " & chr(34) & WSH.ScriptFullName & chr(34) & " ARG", 0
- WScript.Quit
- End If
-
- Dim folderPath, iCount, str, objExec
- folderPath = InputBox("输入要遍历的文件夹路径")
- If isEmpty(folderPath) Then WScript.Quit
-
- iCount = 0
- str = ""
- Set objExec = ws.Exec( "cmd /c dir /b /a-d /s " & chr(34) & folderPath & chr(34) )
-
- Do Until objExec.StdOut.AtEndOfStream
- iCount = iCount + 1
- str = str & objExec.StdOut.ReadLine & vbLf
- If iCount Mod 10 = 0 Then
- MsgBox str
- str = ""
- End If
- Loop
- If str <> "" Then MsgBox str
复制代码
|