Merge pull request #1407 from ZemingLiu/master

add /TASK option
This commit is contained in:
Benjamin Staneck 2017-07-15 17:59:38 +02:00 committed by GitHub
commit b45e3adc67

View File

@ -95,7 +95,7 @@ bool FileExists(const wchar_t * filePath)
return false; 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 #if USE_TASKBAR_API
wchar_t appId[MAX_PATH] = { 0 }; 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); 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); SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
if (!streqi(path.c_str(), L"")) if (!streqi(path.c_str(), L""))
{ {
@ -323,6 +327,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
{ {
StartCmder(opt.second, true); 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")) else if (streqi(opt.first.c_str(), L"/REGISTER"))
{ {
RegisterShellMenu(opt.second, SHELL_MENU_REGISTRY_PATH_BACKGROUND); RegisterShellMenu(opt.second, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
@ -335,7 +343,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
} }
else else
{ {
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n /START <path>\n /SINGLE <path>\n /REGISTER [USER/ALL]\n /UNREGISTER [USER/ALL]", MB_TITLE, MB_OK); MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n /START <path>\n /SINGLE <path>\n /TASK <name>\n /REGISTER [USER/ALL]\n /UNREGISTER [USER/ALL]", MB_TITLE, MB_OK);
return 1; return 1;
} }