http://blog.sina.com.cn/s/blog_6f3da96501011so3.html
Sub Sample1(strPath As String, strName As String)
'strPath: path which to be searched
'strName: filename which will be created  Set WSH = CreateObject("WScript.Shell")
  iFileNum = FreeFile
  sTempFileName = "G:\备份\myfile.bat"
  Open sTempFileName For Output As #iFileNum
  Print #iFileNum, "@echo off"
  Print #iFileNum, "for /f ""delims="" %%i in ('dir " & strPath & " /a-d /b /s /od') do echo %%~ti,%%~dpnxi >> G:\备份\" & strName & ".csv"
  Close #iFileNum'Invoke Batch Program".
  Set wExec = WSH.Exec("%ComSpec% /c" & sTempFileName)
    Do While wExec.Status = 0
        DoEvents
    Loop
    Set wExec = Nothing
    Set WSH = NothingEnd Sub

解决方案 »

  1.   

    仅供参考:
    ServerShare = "\\192.168.3.56\d$"
    UserName = "somedomain\someuser"
    Password = "somepassword"Set NetworkObject = CreateObject("WScript.Network")NetworkObject.MapNetworkDrive "", ServerShare, False, UserName, PasswordSet FSO = CreateObject("Scripting.FileSystemObject")
        Set Directory = FSO.GetFolder(ServerShare)
            For Each FileName In Directory.Files
                WScript.Echo FileName.Name
            Next
            Set FileName = Nothing
        Set Directory = Nothing
    Set FSO = NothingNetworkObject.RemoveNetworkDrive ServerShare, True, FalseSet NetworkObject = Nothing