mirror of
https://github.com/cmderdev/cmder.git
synced 2025-06-13 13:17:55 +08:00
Make "cmder here" work again
The new system works by setting "CMDER_START" if a cmder.exe gets a startup path. The rest is then implemented in the profile.ps1 and init.bat. The new system works as follows: 1.If a startup path is given, cmder.exe sets this as `CMDER_START` and the startup scripts change to that directory. 2.If the usere sets a `CMDER_START` environment variable and this is not overwritten by cmder.exe, this variable is taken as the startup directory by the startup scripts. 3.If not such path is give, the conemu startup dirs is the winner, as the startup scripts don't change anything.
This commit is contained in:
@ -63,10 +63,12 @@ optpair GetOption()
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
// no commandline argument...
|
||||
pair = optpair(L"/START", L"");
|
||||
}
|
||||
else if (argc == 2 && argv[1][0] != L'/')
|
||||
{
|
||||
// only a single argument: this should be a path...
|
||||
pair = optpair(L"/START", argv[1]);
|
||||
}
|
||||
else
|
||||
@ -152,7 +154,10 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
||||
}
|
||||
|
||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||
//SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
||||
if (!streqi(path.c_str(), L""))
|
||||
{
|
||||
SetEnvironmentVariable(L"CMDER_START", path.c_str());
|
||||
}
|
||||
|
||||
// Send out the Settings Changed message - Once using ANSII...
|
||||
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
||||
@ -160,13 +165,6 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
||||
// ...and once using UniCode (because Windows 8 likes it that way).
|
||||
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 5000, NULL);
|
||||
|
||||
HKEY cmderStartRegistryKey;
|
||||
if (RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\cmder", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &cmderStartRegistryKey, 0) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueEx(cmderStartRegistryKey, L"CMDER_START", 0, REG_SZ, (const BYTE*) path.c_str(), path.size() * 2);
|
||||
RegCloseKey(cmderStartRegistryKey);
|
||||
}
|
||||
|
||||
STARTUPINFO si = { 0 };
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
#if USE_TASKBAR_API
|
||||
|
Reference in New Issue
Block a user