question

THOMASWALL-4990 avatar image
0 Votes"
THOMASWALL-4990 asked ·

visual studio c# stuck with ""

sorry with vague title im struggling to make a program i need it to put arguments to cmd but i have more than one quote and keeps seeing links as strings? also im new to this


     private void Playbutton_Click(object sender, RoutedEventArgs e)
     {
         System.Diagnostics.Process process = new System.Diagnostics.Process();
         System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
         startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
         startInfo.FileName = "cmd.exe";
         startInfo.Arguments =  (@"C:\Users\TheDu\Documents\Blox14M\Blox14M.exe -a "http://www.blox14l.tk/" -t  "1" -j  "http://www.blox14l.tk/game/join2014.php?port=%Port%&app=%charapp%&ip=%IP%&username=%user%&id=%id%");
         process.StartInfo = startInfo;
         process.Start();
     }
 }

}

dotnet-csharp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered ·

Hi THOMASWALL-4990,
First, you need to include the "/c" argument to tell cmd.exe what you mean it to do.

 startInfo.Arguments =  (@"/c C:\Users\TheDu\Documents\Blox14M\Blox14M.exe....")

In order to pass multiple command line arguments you should separate each with a space and surround it in quotes in case the argument itself contains a space.
Code looks like:

 ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
             startInfo.WindowStyle = ProcessWindowStyle.Hidden;
          // Start with multiple arguments separated by spaces.
             //  [0] = /a
             //  [1] = /b
             //  [2] = c:\temp
             startInfo.Arguments = "/a /b c:\\temp";
             Process.Start(startInfo);

More details you can refer to this document.
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.