C++;发送报价内的位置 我尝试从C++执行任务调度程序命令,但在引用方面存在问题。p> schtasks /create /sc onlogon /tn Executable /rl highest /tr "\"C:\Program Files\Executable\Executable.exe"\"

C++;发送报价内的位置 我尝试从C++执行任务调度程序命令,但在引用方面存在问题。p> schtasks /create /sc onlogon /tn Executable /rl highest /tr "\"C:\Program Files\Executable\Executable.exe"\",c++,scheduled-tasks,quotes,C++,Scheduled Tasks,Quotes,如何通过WinExec发送这些bat命令 到目前为止我一直在努力 WinExec("schtasks /create /sc onlogon /tn Executable /rl highest /tr \"""C:\\Program Files\\Executable\\Executable.exe\"""", 1); 但这是行不通的。您可以使用原始字符串来避免手动转义字符,例如: WinExec(R"(schtasks /create /sc onlogon /tn Executable

如何通过WinExec发送这些bat命令

到目前为止我一直在努力

WinExec("schtasks /create /sc onlogon /tn Executable /rl highest /tr \"""C:\\Program Files\\Executable\\Executable.exe\"""", 1);

但这是行不通的。

您可以使用原始字符串来避免手动转义字符,例如:

WinExec(R"(schtasks /create /sc onlogon /tn Executable /rl highest /tr "\"C:\Program Files\Executable\Executable.exe"\")", 1);

原始字符串
R”(text)
(C++11)和
std::quoted
(C++14)可能会有帮助。@Jarod42让它的工作像个符咒一样令人惊叹->请发布我可以投票的类似答案->WinExec(R)(schtasks/create/sc onlogon/tn Executable/rl highest/tr“\”C:\Program Files\Executable\Executable.exe“\”,1);提升vs精细转义字符文字,应该是此类问题的标准答案+1+1至@πάνταῥεῖ 用于提供链接。如果您的字符串包含原始字符串文本的起始默认序列,则有一些特殊情况值得研究。