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="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="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="Count" type="dword" data="00000001"/>
</key>

View File

@ -3,6 +3,8 @@
#include <Shlwapi.h>
#include "resource.h"
#include <vector>
#include <Shlobj.h>
#pragma comment(lib, "Shlwapi.lib")
@ -156,14 +158,23 @@ void StartCmder(std::wstring path, bool is_single_mode)
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
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);
}
}
else
{
wchar_t* homeProfile = 0;
SHGetKnownFolderPath(FOLDERID_Profile, 0, NULL, &homeProfile);
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));
}
// Send out the Settings Changed message - Once using ANSII...
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
// ...and once using UniCode (because Windows 8 likes it that way).
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
// 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 };
si.cb = sizeof(STARTUPINFO);
@ -173,8 +184,10 @@ void StartCmder(std::wstring path, bool is_single_mode)
#endif
PROCESS_INFORMATION pi;
CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
if (!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)