Merge pull request #803 from cmderdev/MartiUK-patch-1

Set tasks to always use CMDER_START
This commit is contained in:
Martin Kemp 2016-02-08 18:41:09 +00:00
commit 7962edac56
2 changed files with 26 additions and 13 deletions

View File

@ -527,7 +527,7 @@
<value name="Flags" type="dword" data="00000000"/> <value name="Flags" type="dword" data="00000000"/>
<value name="Hotkey" type="dword" data="00000000"/> <value name="Hotkey" type="dword" data="00000000"/>
<value name="GuiArgs" type="string" data="/icon &quot;%ConEmuDir%\..\git-for-windows\usr\share\git\git-for-windows.ico&quot;"/> <value name="GuiArgs" type="string" data="/icon &quot;%ConEmuDir%\..\git-for-windows\usr\share\git\git-for-windows.ico&quot;"/>
<value name="Cmd1" type="string" data="*%ConEmuDir%\..\git-for-windows\usr\bin\mintty.exe /bin/bash -l -new_console:d:%userProfile%"/> <value name="Cmd1" type="string" data="*%ConEmuDir%\..\git-for-windows\usr\bin\mintty.exe /bin/bash -l -new_console:d:%USERPROFILE%"/>
<value name="Active" type="dword" data="00000000"/> <value name="Active" type="dword" data="00000000"/>
<value name="Count" type="dword" data="00000001"/> <value name="Count" type="dword" data="00000001"/>
</key> </key>

View File

@ -3,6 +3,8 @@
#include <Shlwapi.h> #include <Shlwapi.h>
#include "resource.h" #include "resource.h"
#include <vector> #include <vector>
#include <Shlobj.h>
#pragma comment(lib, "Shlwapi.lib") #pragma comment(lib, "Shlwapi.lib")
@ -153,17 +155,26 @@ 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);
} }
SetEnvironmentVariable(L"CMDER_ROOT", exeDir); SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
if (!streqi(path.c_str(), L"")) if (!streqi(path.c_str(), L""))
{ {
SetEnvironmentVariable(L"CMDER_START", path.c_str()); if (!SetEnvironmentVariable(L"CMDER_START", path.c_str())) {
MessageBox(NULL, _T("Error trying to set CMDER_START to given path!"), _T("Error"), MB_OK);
} }
}
// Send out the Settings Changed message - Once using ANSII... else
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL); {
wchar_t* homeProfile = 0;
// ...and once using UniCode (because Windows 8 likes it that way). SHGetKnownFolderPath(FOLDERID_Profile, 0, NULL, &homeProfile);
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL); if (!SetEnvironmentVariable(L"CMDER_START", homeProfile)) {
MessageBox(NULL, _T("Error trying to set CMDER_START to USER_PROFILE!"), _T("Error"), MB_OK);
}
CoTaskMemFree(static_cast<void*>(homeProfile));
}
// Ensure EnvironmentVariables are propagated.
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL); // For Windows >= 8
STARTUPINFO si = { 0 }; STARTUPINFO si = { 0 };
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
@ -173,8 +184,10 @@ void StartCmder(std::wstring path, bool is_single_mode)
#endif #endif
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
if (!CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) {
CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi); MessageBox(NULL, _T("Unable to create the ConEmu Process!"), _T("Error"), MB_OK);
return;
}
} }
bool IsUserOnly(std::wstring opt) bool IsUserOnly(std::wstring opt)