gpt4 book ai didi

c# - 使用 Writeline 创建批处理文件

转载 作者:行者123 更新时间:2023-11-30 19:27:47 24 4
gpt4 key购买 nike

尝试使用下面的代码使用 writeline 创建批处理文件。但是,由于文件路径中的空格,第三行似乎不会在批处理文件中运行。我试图将其包含在 """"中,但这会产生 6 个新错误。谢谢,我对此很陌生,只是想弄清楚一些道理。在网上搜索后,似乎无法找到解决方案。

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();

最佳答案

您需要使用 \" 转义额外的引号

"\"C:\\Program Files\\McAfee\\Common Framework\\cmdagent.exe\" /p");

关于c# - 使用 Writeline 创建批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17790860/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com