[USERINIT] Start shell from profile path

When the shell is assigned to cmd.exe, open to the logged in user's profile path. This appears to match the behavior of Windows Server 2003 userinit. It is also a prerequisite for ReactOS Server Core.
This commit is contained in:
Carl J. Bialorucki
2026-06-08 10:11:57 -05:00
parent d1c281c95e
commit 2263c9ca0f
+13 -3
View File
@@ -21,7 +21,7 @@
* PROJECT: ReactOS Userinit Logon Application
* FILE: base/system/userinit/userinit.c
* PROGRAMMERS: Thomas Weidenmueller ([email protected])
* Hervé Poussineau ([email protected])
* Hervé Poussineau ([email protected])
*/
#include "userinit.h"
@@ -184,7 +184,9 @@ StartProcess(
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
WCHAR ExpandedCmdLine[MAX_PATH];
WCHAR ExpandedCmdLine[MAX_PATH], ProfilePath[MAX_PATH];
HANDLE hToken;
PWCHAR WorkingDir = NULL;
ExpandEnvironmentStringsW(CommandLine, ExpandedCmdLine, ARRAYSIZE(ExpandedCmdLine));
@@ -194,6 +196,14 @@ StartProcess(
si.wShowWindow = SW_SHOWNORMAL;
ZeroMemory(&pi, sizeof(pi));
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
{
DWORD PathSize = _countof(ProfilePath);
if (GetUserProfileDirectoryW(hToken, ProfilePath, &PathSize))
WorkingDir = ProfilePath;
CloseHandle(hToken);
}
if (!CreateProcessW(NULL,
ExpandedCmdLine,
NULL,
@@ -201,7 +211,7 @@ StartProcess(
FALSE,
NORMAL_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT,
pEnvironment,
NULL,
WorkingDir,
&si,
&pi))
{