diff --git a/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp b/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp index f7ce16587..6b38d8894 100644 --- a/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp +++ b/source/MaaAdbControlUnit/Base/ProcessArgvGenerator.cpp @@ -34,16 +34,9 @@ std::optional ProcessArgvGenerator::gen(const string_replace_all_(s, replacement); } - std::filesystem::path abs_path; - if (auto raw_path = MAA_NS::path(res.front()); raw_path.is_absolute()) { - abs_path = raw_path; - } - else { - abs_path = boost::process::search_path(raw_path); - } - + std::filesystem::path abs_path = boost::process::search_path(path(res.front())); if (!std::filesystem::exists(abs_path)) { - LogError << "exec path not exists" << VAR(abs_path); + LogError << "exec path not exists" << VAR(res.front()) << VAR(abs_path); return std::nullopt; } diff --git a/source/MaaFramework/Task/Component/CommandAction.cpp b/source/MaaFramework/Task/Component/CommandAction.cpp index 61da2bfcf..ca4c6c75c 100644 --- a/source/MaaFramework/Task/Component/CommandAction.cpp +++ b/source/MaaFramework/Task/Component/CommandAction.cpp @@ -4,14 +4,16 @@ #include "Utils/Codec.h" #include "Utils/IOStream/BoostIO.hpp" +#include "Utils/ImageIo.h" #include "Utils/Logger.h" #include "Utils/Platform.h" -#include "Utils/ImageIo.h" MAA_TASK_NS_BEGIN CommandAction::~CommandAction() { + LogFunc; + for (const auto& p : cached_images_) { if (!std::filesystem::exists(p)) { continue; @@ -32,7 +34,11 @@ bool CommandAction::run(const MAA_RES_NS::Action::CommandParam& command, const R { "{Box}", std::bind(&CommandAction::gen_box, this, std::placeholders::_1) }, }; - std::filesystem::path exec = path(command.exec); + std::filesystem::path exec = boost::process::search_path(path(command.exec)); + if (!std::filesystem::exists(exec)) { + LogError << "exec not exists" << VAR(command.exec) << VAR(exec); + return false; + } std::vector args; for (const std::string& arg : command.args) {