VB 调用 Shell 执行 CMD 命令的问题
Public Const aa As String = "c:\text.txt"'
Sub a()
Dim bb As String
bb = MyPat & "\123.txt"
' MsgBox bb ' 这里,bb变量能得到实际的值
Shell ("cmd /c ping www.baidu.com >>" & bb), vbHide ' 执行不成功,,不知道如何修改才可以?
Shell ("cmd /c ping www.baidu.com >>" & aa), vbHide ' 执行成功
End Sub
Public Function MyPat() As String ' 获取我的文档目录
Dim WSHShell As Object
Set WSHShell = CreateObject("Wscript.Shell")
MyPat = WSHShell.SpecialFolders("MyDocuments")
Set WSHShell = Nothing
End Function