mirror of
https://github.com/cmderdev/cmder.git
synced 2025-03-15 07:04:39 +08:00
cleanup
This commit is contained in:
parent
0a691cb7ee
commit
d8238b0230
@ -105,7 +105,7 @@ bool FileExists(const wchar_t * filePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring title = L"", std::wstring iconPath = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"")
|
||||
void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring title = L"", std::wstring iconPath = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"", bool admin = false)
|
||||
{
|
||||
#if USE_TASKBAR_API
|
||||
wchar_t appId[MAX_PATH] = { 0 };
|
||||
@ -602,8 +602,36 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
|
||||
|
||||
// MessageBox(NULL, terminalPath, _T("Error"), MB_OK);
|
||||
// MessageBox(NULL, args, _T("Error"), MB_OK);
|
||||
// Let's try to rerun as Administrator
|
||||
SHELLEXECUTEINFO sei = { sizeof(sei) };
|
||||
sei.fMask = SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS;
|
||||
sei.lpVerb = L"runas";
|
||||
sei.lpFile = terminalPath;
|
||||
sei.lpParameters = args;
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
|
||||
if (admin && ShellExecuteEx(&sei))
|
||||
{
|
||||
if (!sei.hProcess)
|
||||
{
|
||||
Sleep(500);
|
||||
_ASSERTE(sei.hProcess != nullptr);
|
||||
}
|
||||
|
||||
if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi))
|
||||
if (sei.hProcess)
|
||||
{
|
||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
}
|
||||
|
||||
// int nZone = 0;
|
||||
// if (!HasZoneIdentifier(lsFile, nZone)
|
||||
// || (nZone != 0 /*LocalComputer*/))
|
||||
// {
|
||||
// // Assuming that elevated copy has fixed all zone problems
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
else if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi))
|
||||
{
|
||||
if (PathFileExists(windowsTerminalDir))
|
||||
{
|
||||
@ -734,6 +762,7 @@ struct cmderOptions
|
||||
std::wstring cmderIcon = L"";
|
||||
std::wstring cmderRegScope = L"USER";
|
||||
std::wstring cmderTerminalArgs = L"";
|
||||
bool cmderAdmin = false;
|
||||
bool cmderSingle = false;
|
||||
bool cmderUserCfg = true;
|
||||
bool registerApp = false;
|
||||
@ -822,6 +851,10 @@ cmderOptions GetOption()
|
||||
{
|
||||
cmderOptions.cmderUserCfg = false;
|
||||
}
|
||||
else if (_wcsicmp(L"/a", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir) && !PathFileExists(conEmuDir))
|
||||
{
|
||||
cmderOptions.cmderAdmin = true;
|
||||
}
|
||||
else if (_wcsicmp(L"/register", szArgList[i]) == 0)
|
||||
{
|
||||
cmderOptions.registerApp = true;
|
||||
@ -958,8 +991,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderTitle, cmderOptions.cmderIcon, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderTerminalArgs);
|
||||
}
|
||||
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderTitle, cmderOptions.cmderIcon, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderTerminalArgs, cmderOptions.cmderAdmin); }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user