I'm running some code in C# where I call a batch file, and I need to pass a Path with space as an argument and it does not work.
I have tried to call my argument different ways in the batch %1 , %~1, "%1", '%1'. None of these work. Also in my C# code I tried to convert it to string and it wont work either
C# code.
string argument = textBox10.Text.ToString() ;
string command = @"/c powershell -executionpolicy unrestricted X:\PathToBatch\Run.bat" + " " + argument;
System.Diagnostics.Process.Start("cmd.exe", command);
Batch code :
echo %1
Pause
When I pass an argument C:\Program Files\Test as a directory, it prints "C:\Program" and stops at the space. How can I get the full path ?