From 728e83a85bea6ad7b4ddda0b960c443e3ef9f737 Mon Sep 17 00:00:00 2001 From: Martin Kemp Date: Tue, 9 Feb 2016 13:40:32 +0000 Subject: [PATCH] Set CMDER_START to homeprofile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is to set CMDER_START to home when no directory is given. This is to ensure it is set even though it will default to the home directory anyway. It’ll allow users to use CMDER_START even if started without a path. --- launcher/src/CmderLauncher.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index b2b0ffa..4982fd0 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -3,6 +3,7 @@ #include #include "resource.h" #include +#include #pragma comment(lib, "Shlwapi.lib") @@ -155,7 +156,16 @@ void StartCmder(std::wstring path, bool is_single_mode) } SetEnvironmentVariable(L"CMDER_ROOT", exeDir); - if (!streqi(path.c_str(), L"")) + if (streqi(path.c_str(), L"")) + { + 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 given path!"), _T("Error"), MB_OK); + } + CoTaskMemFree(static_cast(homeProfile)); + } + else { if (!SetEnvironmentVariable(L"CMDER_START", path.c_str())) { MessageBox(NULL, _T("Error trying to set CMDER_START to given path!"), _T("Error"), MB_OK);