Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Writeline to create a batch file

Trying to use the code below to use writeline to create a batch file. However it seems that the third line won't run in a batch file due to the spaces in the file path. I have tried to enclose in "" "" but that creates 6 new errors. Thanks I am new to this just trying to make some sense. After searching the web the just can't seem to find a solution.

StreamWriter w = new StreamWriter(@"C:\temp\InstallAgent.bat");
w.WriteLine("C:\\temp\\framepkg.exe /install=agent /silent");
w.WriteLine("C:\\PRogram Files\\McAfee\\Common Framework\\cmdagent.exe /p");
w.Close();
like image 593
user2607277 Avatar asked Sep 13 '26 20:09

user2607277


1 Answers

You need to escape the extra quotes with \"

"\"C:\\Program Files\\McAfee\\Common Framework\\cmdagent.exe\" /p");
like image 58
Gray Avatar answered Sep 16 '26 10:09

Gray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!