0

I have a problem when sending a command from my C# application. I want to execute an .exe file with some using quotes in parameter values but cannot find a way to do so. What I need to execute is something like that:

C:/Program Files/.../my_exe.exe /path1="C:/Temp/Myfile.txt"

I do the following :

var request = "C:/Program Files/.../my_exe.exe /path1=C:/Temp/Myfile.txt";
Process.Start(request);

If I send the command without quotes then it is not working. Then I tried to send quotes using \", or \u0022, but both of them send me \" instead of just quotes.

Any further ideas please?

Zverev Evgeniy
  • 3,643
  • 25
  • 42
Siegfried.V
  • 1,508
  • 1
  • 16
  • 34
  • Note how in the duplicate he has a comma in the `Process.Start()` command which is selecting [this overload](https://msdn.microsoft.com/en-us/library/h6ak8zt5(v=vs.110).aspx), you should do the same thing because this uses the API to pass in the arguments instead "starting" a string that has arguments in it. Even after you do that you should still pass in the escaped quotes which is required by some programs when the path has spaces: `Process.Start("C:/Program Files/.../my_exe.exe", "/path1=\"C:/Temp/Myfile.txt\"");` (note how I added in escaped quotes). – Quantic Dec 21 '16 at 18:10
  • already red that post, but don't understand use of @, I guessed this was for JavaScript? – Siegfried.V Dec 21 '16 at 18:11
  • @Siegfried.V You are wrong. That is C#. The `@` symbol is an instruction to ignore escape symbols in the string constant. – Zverev Evgeniy Dec 21 '16 at 18:12
  • Thanks Quantic, I tested it and it is working... didn't know it was obligatory to send as 2 separated strings, making as you say it is working fine – Siegfried.V Dec 21 '16 at 18:19

0 Answers0