4

gnokiiを使用してSMSを送信しています。

私のVBコード:

Dim xCmd As String
xCmd = "cmd.exe /c echo msgcontent "| c:\gnokii\gnokii.exe --sendsms 12345678"
Shell(xCmd)

注意点:

  1. 出力を.txtファイルにリダイレクトしようとしましたが、.txtファイルが空のようです。さらに、プログラムは毎秒複数のSMSを送信する必要がある場合があるため、.txtを作成することはできません。

  2. gnokii.exeが実行されているかどうかを確認する必要があるため、Process.Start()は実行できません。

  3. SMSが正常に送信されたかどうかを確認するための出力が必要です。

  4. (以下のコード)を使用してみましたが、どちらも機能しませんでした。出力は表示されませんでした。

    関数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

4 に答える 4

3

これを試して:

    Dim p As Process = New Process
    Dim output As String

    With p
        .StartInfo.CreateNoWindow = True
        .StartInfo.RedirectStandardOutput = True
        .StartInfo.UseShellExecute = False
        .StartInfo.FileName = fileName
        .StartInfo.Arguments = args
        .Start()
        output = .StandardOutput.ReadToEnd
        .WaitForExit()
    End With

    Return output
于 2011-06-19T03:40:32.050 に答える
1

出力を.txtファイルに送信するには(私が見つけることができる最善の解決策)

交換

xCmd = "cmd.exe /c echo msgcontent "| c:\gnokii\gnokii.exe --sendsms 12345678 > file.txt"

xCmd = "cmd.exe /c echo msgcontent "| c:\gnokii\gnokii.exe --sendsms 12345678 2> file.txt"
于 2011-06-20T00:24:37.773 に答える
0

この100%の作品を使用できますが、結果のみが表示されます

vb.netでシェルの結果を表示する方法:

'create 1 textbox1
'create 1 button1
'create 1 richtextbox1
'in the start up directory of this program make a file could 123.text
'------------------------------------------------------------------------
Dim read As System.IO.StreamReader
read = File.OpenText(Application.StartupPath & "\123.text")

Shell("cmd.exe /c" & TextBox1.Text + ">123.text")
Do Until read.EndOfStream
    RichTextBox1.Text = read.ReadLine & vbCrLf
Loop
'--------------------------------------------------------------------------
'you can add on the top to create the file if it does not exists,   

If IO.File.Exists(Application.StartupPath & "\123.text") = False Then
    IO.File.Create(Application.StartupPath & "\123.text")
End If
'-------------------------------------------------------------------------

コードはこのリンクhttp://pastebin.com/iEhv61jGでも入手できます。

于 2013-02-22T23:14:49.203 に答える
0

私自身、このようなことを提案するかもしれません。これは他の誰かが投稿したものと似ていますが、もう少し機能を提供していると思います。

Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Shell("cmd.exe /c " & TextBox1.Text + " > c:\temp\output.txt")
    Dim read As System.IO.StreamReader
    read = File.OpenText("c:\temp\output.txt")
    RichTextBox1.Clear()
    Do Until read.EndOfStream
        RichTextBox1.Text += read.ReadLine & vbCrLf
    Loop
    RichTextBox1.Select(RichTextBox1.Text.Length, 0)
    RichTextBox1.ScrollToCaret()
End Sub
End Class
于 2014-02-25T19:28:23.217 に答える