如何从cmd外壳读取VB.NET中的cmd输出?
|
我正在使用gnokii发送SMS。
我的VB代码:
Dim xCmd As String
xCmd = \"cmd.exe /c echo msgcontent \"| c:\\gnokii\\gnokii.exe --sendsms 12345678\"
Shell(xCmd)
注意事项:
我确实尝试将输出重定向到.txt文件,但.txt文件似乎为空。此外,该程序可能必须每秒发送多个SMS,因此创建.txt是不可行的。
Process.Start()不可行,因为我必须检查gnokii.exe是否正在运行。
我需要输出来检查SMS是否成功发送。
我尝试使用(下面的代码),但是也没有用;没有显示输出。
函数exe(ByVal fileName,ByVal args)
Dim p As Process = New Process
Dim output As String
With p
.StartInfo.CreateNoWindow = True
.StartInfo.UseShellExecute = False
.StartInfo.RedirectStandardOutput = True
.StartInfo.FileName = fileName
.StartInfo.Arguments = args
.Start()
output = .StandardOutput.ReadToEnd
End With
Return output
结束功能
没有找到相关结果
已邀请:
4 个回复
祁澈盘哼颗
曝匿弄罚
与
膛嵌墒缅欠
该代码也可以从以下链接获得:http://pastebin.com/iEhv61jG
公藕