From 74d79ea62887c57d7eabd2dd4e9eef9e050464c1 Mon Sep 17 00:00:00 2001 From: "Wild.Farmer" Date: Sat, 17 Jun 2017 22:29:06 +0800 Subject: [PATCH] add /TASK option --- launcher/src/CmderLauncher.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 42f2902..164b87e 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -95,7 +95,7 @@ bool FileExists(const wchar_t * filePath) return false; } -void StartCmder(std::wstring path, bool is_single_mode) +void StartCmder(std::wstring path, bool is_single_mode, std::wstring taskName = L"") { #if USE_TASKBAR_API wchar_t appId[MAX_PATH] = { 0 }; @@ -180,6 +180,10 @@ void StartCmder(std::wstring path, bool is_single_mode) swprintf_s(args, L"/Icon \"%s\" /Title Cmder", icoPath); } + if (!taskName.empty()) { + swprintf_s(args, L"%s -run {%s}", args, taskName.c_str()); + } + SetEnvironmentVariable(L"CMDER_ROOT", exeDir); if (!streqi(path.c_str(), L"")) { @@ -323,6 +327,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, { StartCmder(opt.second, true); } + else if (streqi(opt.first.c_str(), L"/TASK")) + { + StartCmder(L"", false, opt.second); + } else if (streqi(opt.first.c_str(), L"/REGISTER")) { RegisterShellMenu(opt.second, SHELL_MENU_REGISTRY_PATH_BACKGROUND); @@ -335,7 +343,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } else { - MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n /START \n /SINGLE \n /REGISTER [USER/ALL]\n /UNREGISTER [USER/ALL]", MB_TITLE, MB_OK); + MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n /START \n /SINGLE \n /TASK \n /REGISTER [USER/ALL]\n /UNREGISTER [USER/ALL]", MB_TITLE, MB_OK); return 1; }