diff --git a/src/widgets/krun.cpp b/src/widgets/krun.cpp --- a/src/widgets/krun.cpp +++ b/src/widgets/krun.cpp @@ -361,9 +361,18 @@ bool canRun = true; bool isFileExecutable = hasExecuteBit(u.toLocalFile()); +#ifdef Q_OS_WIN + // On Windows, run all executables normally + bool runWindowsExecutable = true; +#else + // On non-Windows systems, this will prevent Windows executables + // from being run, so that programs like Wine can handle them instead. + bool runWindowsExecutable = !mime.inherits(QStringLiteral("application/x-ms-dos-executable")); +#endif + // For executables that aren't scripts and without execute bit, // show prompt asking user if he wants to run the program. - if (!isFileExecutable && !isTextFile) { + if (!isFileExecutable && !isTextFile && runWindowsExecutable) { canRun = false; int result = showUntrustedProgramWarning(u.fileName(), window); if (result == QDialog::Accepted) { @@ -378,9 +387,10 @@ canRun = true; } } - } else if (!isFileExecutable && isTextFile) { - // Don't try to run scripts without execute bit, instead - // open them with default application + } else if ((!isFileExecutable && isTextFile) || !runWindowsExecutable) { + // Don't try to run scripts without execute bit or any + // Windows executables on non-Windows systems, + // instead open them with default application canRun = false; }