mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
Merge pull request #803 from cmderdev/MartiUK-patch-1
Set tasks to always use CMDER_START
This commit is contained in:
commit
7962edac56
@ -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 "%ConEmuDir%\..\git-for-windows\usr\share\git\git-for-windows.ico""/>
|
||||
<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>
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <Shlwapi.h>
|
||||
#include "resource.h"
|
||||
#include <vector>
|
||||
#include <Shlobj.h>
|
||||
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||
if (!streqi(path.c_str(), L""))
|
||||
{
|
||||
SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||
if (!streqi(path.c_str(), L""))
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user