我正在尝试从 C++ 执行任务调度程序命令,但引号有问题。
schtasks /create /sc onlogon /tn Executable /rl highest /tr "\"C:\Program Files\Executable\Executable.exe"\"
如何通过 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);
关于C++ 在引号内发送位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30007618/