Skip to content

Commit

Permalink
Set CMDER_START to homeprofile
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MartiUK committed Feb 9, 2016
1 parent 95f6096 commit 728e83a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion launcher/src/CmderLauncher.cpp
Expand Up @@ -3,6 +3,7 @@
#include <Shlwapi.h>
#include "resource.h"
#include <vector>
#include <Shlobj.h>


#pragma comment(lib, "Shlwapi.lib")
Expand Down Expand Up @@ -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<void*>(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);
Expand Down

1 comment on commit 728e83a

@jankatins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartiUK I'm still not sure why this is needed, as this makes all the -new_console:d:%USERPROFILE% in the conemu task definitions unnecessary, as this is now always overwritten as CMDER_START is set. The commit message doesn't tell what the (user visible) bug was which should be fixed here :-(

Please sign in to comment.