mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[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:
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user