VBscript code to capture stdout, without showing console window

前端 未结 7 634
生来不讨喜
生来不讨喜 2020-11-28 11:48

This is a VBScript code example that shows how to catch whatever a command line program sends to standard output. It executes the command xcopy /? and shows the

7条回答
  •  囚心锁ツ
    2020-11-28 12:36

    To return in VBA all subfolders in G:\OF

    sub M_snb()
      c00= createobejct("wscript.Shell").exec("cmd /c Dir G:\OF\*. /s/b").stdout.readall
    end sub
    

    to split the returned string into an array

    sub M_snb()
      sn=split(createobejct("wscript.Shell").exec("cmd /c Dir G:\OF\*. /s/b").stdout.readall,vbCrLf)
    
      for j=0 to ubound(sn)
         msgbox sn(j)
      next
    End Sub
    

提交回复
热议问题