热心网友
回答时间:2024-04-29 05:10
Shell恐怕不行·
给你个现成的:
Sub _CMD(ByVal Data As String)
Try
Dim p As New Process()‘用Process就可以
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.CreateNoWindow = True
p.Start()
Application.DoEvents()
p.StandardInput.WriteLine(Data)’这个Data就是cmd命令
p.StandardInput.WriteLine("Exit")‘这个是退出语句
Dim strRst As String = p.StandardOutput.ReadToEnd()’执行完语句后取得显示内容.
p.Close()
Catch ex As Exception
End Try
‘之后就是你自己的代码了...
End Sub
收起