@@ -105,11 +105,11 @@ bool FileExists(const wchar_t * filePath)
105105 return false ;
106106}
107107
108- 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 )
108+ 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" " )
109109{
110- #if USE_TASKBAR_API
111- wchar_t appId[MAX_PATH] = { 0 };
112- #endif
110+ #if USE_TASKBAR_API
111+ wchar_t appId[MAX_PATH] = { 0 };
112+ #endif
113113 wchar_t exeDir[MAX_PATH] = { 0 };
114114 wchar_t icoPath[MAX_PATH] = { 0 };
115115 wchar_t cfgPath[MAX_PATH] = { 0 };
@@ -153,9 +153,9 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
153153
154154 GetModuleFileName (NULL , exeDir, sizeof (exeDir));
155155
156- #if USE_TASKBAR_API
157- wcscpy_s (appId, exeDir);
158- #endif
156+ #if USE_TASKBAR_API
157+ wcscpy_s (appId, exeDir);
158+ #endif
159159
160160 PathRemoveFileSpec (exeDir);
161161
@@ -651,44 +651,13 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
651651 STARTUPINFO si = { 0 };
652652
653653 si.cb = sizeof (STARTUPINFO);
654- #if USE_TASKBAR_API
655- si.lpTitle = appId;
656- si.dwFlags = STARTF_TITLEISAPPID;
657- #endif
654+ #if USE_TASKBAR_API
655+ si.lpTitle = appId;
656+ si.dwFlags = STARTF_TITLEISAPPID;
657+ #endif
658658 PROCESS_INFORMATION pi;
659659
660- // MessageBox(NULL, terminalPath, _T("Error"), MB_OK);
661- // MessageBox(NULL, args, _T("Error"), MB_OK);
662- // Let's try to rerun as Administrator
663- SHELLEXECUTEINFO sei = { sizeof (sei) };
664- sei.fMask = SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS;
665- sei.lpVerb = L" runas" ;
666- sei.lpFile = terminalPath;
667- sei.lpParameters = args;
668- sei.nShow = SW_SHOWNORMAL;
669-
670- if (admin && ShellExecuteEx (&sei))
671- {
672- if (!sei.hProcess )
673- {
674- Sleep (500 );
675- _ASSERTE (sei.hProcess != nullptr );
676- }
677-
678- if (sei.hProcess )
679- {
680- WaitForSingleObject (sei.hProcess , INFINITE);
681- }
682-
683- // int nZone = 0;
684- // if (!HasZoneIdentifier(lsFile, nZone)
685- // || (nZone != 0 /*LocalComputer*/))
686- // {
687- // // Assuming that elevated copy has fixed all zone problems
688- // break;
689- // }
690- }
691- else if (!CreateProcess (terminalPath, args, NULL , NULL , false , 0 , NULL , NULL , &si, &pi))
660+ if (!CreateProcess (terminalPath, args, NULL , NULL , false , 0 , NULL , NULL , &si, &pi))
692661 {
693662 if (PathFileExists (windowsTerminalDir))
694663 {
@@ -819,7 +788,6 @@ struct cmderOptions
819788 std::wstring cmderIcon = L" " ;
820789 std::wstring cmderRegScope = L" USER" ;
821790 std::wstring cmderTerminalArgs = L" " ;
822- bool cmderAdmin = false ;
823791 bool cmderSingle = false ;
824792 bool cmderUserCfg = true ;
825793 bool registerApp = false ;
@@ -908,10 +876,6 @@ cmderOptions GetOption()
908876 {
909877 cmderOptions.cmderUserCfg = false ;
910878 }
911- else if (_wcsicmp (L" /a" , szArgList[i]) == 0 && !PathFileExists (windowsTerminalDir) && !PathFileExists (conEmuDir))
912- {
913- cmderOptions.cmderAdmin = true ;
914- }
915879 else if (_wcsicmp (L" /register" , szArgList[i]) == 0 )
916880 {
917881 cmderOptions.registerApp = true ;
@@ -1048,7 +1012,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
10481012 }
10491013 else
10501014 {
1051- StartCmder (cmderOptions.cmderStart , cmderOptions.cmderSingle , cmderOptions.cmderTask , cmderOptions.cmderTitle , cmderOptions.cmderIcon , cmderOptions.cmderCfgRoot , cmderOptions.cmderUserCfg , cmderOptions.cmderTerminalArgs , cmderOptions.cmderAdmin ); }
1015+ StartCmder (cmderOptions.cmderStart , cmderOptions.cmderSingle , cmderOptions.cmderTask , cmderOptions.cmderTitle , cmderOptions.cmderIcon , cmderOptions.cmderCfgRoot , cmderOptions.cmderUserCfg , cmderOptions.cmderTerminalArgs );
1016+ }
10521017
10531018 return 0 ;
10541019}
0 commit comments