C++在引号内发送位置

C++ send location inside of quotes

本文关键字:位置 C++      更新时间:2023-10-16

我试图从 c++ 执行任务调度程序命令,但引号有问题。

schtasks /create /sc onlogon /tn Executable /rl highest /tr ""C:Program FilesExecutableExecutable.exe""

如何通过 WinExec 发送这些蝙蝠命令?

到目前为止我尝试了这个

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 FilesExecutableExecutable.exe"")", 1);