mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 22:14:32 +00:00
Invoke system's cmd.exe directly.
This commit is contained in:
parent
705d7730dc
commit
3846a5b875
@ -261,7 +261,12 @@ void Application::runExternalProgram(BitTorrent::TorrentHandle *const torrent) c
|
|||||||
#if defined(Q_OS_UNIX)
|
#if defined(Q_OS_UNIX)
|
||||||
QProcess::startDetached(QLatin1String("/bin/sh"), {QLatin1String("-c"), program});
|
QProcess::startDetached(QLatin1String("/bin/sh"), {QLatin1String("-c"), program});
|
||||||
#elif defined(Q_OS_WIN) // test cmd: `echo "%F" > "c:\ab ba.txt"`
|
#elif defined(Q_OS_WIN) // test cmd: `echo "%F" > "c:\ab ba.txt"`
|
||||||
program.prepend(QLatin1String("cmd.exe /C "));
|
static const QString cmdPath = []() -> QString {
|
||||||
|
WCHAR systemPath[64] = {0};
|
||||||
|
GetSystemDirectoryW(systemPath, sizeof(systemPath) / sizeof(WCHAR));
|
||||||
|
return QString::fromWCharArray(systemPath) + QLatin1String("\\cmd.exe /C ");
|
||||||
|
}();
|
||||||
|
program.prepend(cmdPath);
|
||||||
const uint cmdMaxLength = 32768; // max length (incl. terminate char) for `lpCommandLine` in `CreateProcessW()`
|
const uint cmdMaxLength = 32768; // max length (incl. terminate char) for `lpCommandLine` in `CreateProcessW()`
|
||||||
if ((program.size() + 1) > cmdMaxLength) {
|
if ((program.size() + 1) > cmdMaxLength) {
|
||||||
logger->addMessage(tr("Torrent: %1, run external program command too long (length > %2), execution failed.").arg(torrent->name()).arg(cmdMaxLength), Log::CRITICAL);
|
logger->addMessage(tr("Torrent: %1, run external program command too long (length > %2), execution failed.").arg(torrent->name()).arg(cmdMaxLength), Log::CRITICAL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user