我正在使用gnokii发送短信。如何从cmd shell读取VB.NET中的cmd输出?
我的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文件名,BYVAL参数)
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
端功能
如果您将xCMD更改为具有> c:\ xxx.txt,xxx.txt的内容是否包含您想要的输出? – BugFinder
也许[此链接](http://stackoverflow.com/questions/2162078/pick-up-strings-from-cmd-command-process-startinfo)将有所帮助。 –
@BugFinder不要它 – Joyce