Search code examples
c#command-lineparametersgammu

Start gammu with parameters


I would like to use gammu to send text messages with address and message, but I have a problem with the gammu parameters. If I start only the program it runs (string cmd1 = "c:\\G133\\bin\\gammu.exe ";). After adding parameters it gives this failure:

System.ComponentModel.Win32Exception' occurred in System.dll
Additional information: The system cannot find the file specified:

Code:

string[] sms = File.ReadAllLines(@"C:\\temp\\test.txt");

string address = sms[0];
string message = sms[1];

string cmd1 = @"C:\G133\bin\gammu.exe --sendsms TEXT" + " " +  
    "\"" + address + "\" -text " + " " + "\"" + message + "\"";

System.Diagnostics.Process.Start(cmd1);

Can anyone help me? Thanks in advance.

The output looks well:

Console.WriteLine(cmd1); - result

C:\G133\bin\gammu.exe --sendsms TEXT +12121234567 -text "Hello"

Solution

  • You need to call the overload of Start method which takes two parameters:

    • First one: the file to run;
    • Second one: the parameters

    And it will looks like:

    string app = @"path\to\your\target\app";
    string prms = "your parameters";
    
    System.Diagnostics.Process.Start(app, prms);