Index: base/setup/setup/setup.c =================================================================== --- base/setup/setup/setup.c (revision 40105) +++ base/setup/setup/setup.c (working copy) @@ -60,9 +60,6 @@ HMODULE hDll; PINSTALL_REACTOS InstallReactOS; - /* some dlls (loaded by syssetup) need a valid user profile */ - InitializeProfiles(); - hDll = LoadLibrary (TEXT("syssetup")); if (hDll == NULL) { Index: dll/win32/userenv/setup.c =================================================================== --- dll/win32/userenv/setup.c (revision 40105) +++ dll/win32/userenv/setup.c (working copy) @@ -178,13 +178,44 @@ /* Set 'DefaultUserProfile' value */ wcscpy(szBuffer, L"Default User"); - if (!AppendSystemPostfix(szBuffer, MAX_PATH)) + + /* Create Default User profile directory path */ + wcscpy(szProfilePath, szProfilesPath); + wcscat(szProfilePath, L"\\"); + wcscat(szProfilePath, szBuffer); + + /* Attempt default user directory creation */ + if (!CreateDirectoryW (szProfilePath, NULL)) { - DPRINT1("AppendSystemPostfix() failed\n", GetLastError()); - RegCloseKey(hKey); - return FALSE; + if (GetLastError() != ERROR_ALREADY_EXISTS) + { + DPRINT1("Error: %lu\n", GetLastError()); + return FALSE; + } + /* Directory existed, let's try to append the postfix */ + if (!AppendSystemPostfix(szBuffer, MAX_PATH)) + { + DPRINT1("AppendSystemPostfix() failed\n", GetLastError()); + RegCloseKey(hKey); + return FALSE; + } + /* Attempt again creation with appended postfix */ + wcscpy(szProfilePath, szProfilesPath); + wcscat(szProfilePath, L"\\"); + wcscat(szProfilePath, szBuffer); + if (!CreateDirectoryW(szProfilePath, NULL)) + { + if (GetLastError() != ERROR_ALREADY_EXISTS) + { + DPRINT1("Error: %lu\n", GetLastError()); + RegCloseKey(hKey); + return FALSE; + } + } + } + dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR); Error = RegSetValueExW(hKey, L"DefaultUserProfile", @@ -202,18 +233,6 @@ RegCloseKey(hKey); - /* Create 'Default User' profile directory */ - wcscpy(szProfilePath, szProfilesPath); - wcscat(szProfilePath, L"\\"); - wcscat(szProfilePath, szBuffer); - if (!CreateDirectoryW (szProfilePath, NULL)) - { - if (GetLastError() != ERROR_ALREADY_EXISTS) - { - DPRINT1("Error: %lu\n", GetLastError()); - return FALSE; - } - } /* Set current user profile */ SetEnvironmentVariableW(L"USERPROFILE", szProfilePath); @@ -381,11 +400,42 @@ /* Set 'AllUsersProfile' value */ wcscpy(szBuffer, L"All Users"); - if (!AppendSystemPostfix(szBuffer, MAX_PATH)) + + /* Create 'All Users' profile directory path */ + wcscpy(szProfilePath, szProfilesPath); + wcscat(szProfilePath, L"\\"); + wcscat(szProfilePath, szBuffer); + + /* Attempt 'All Users' directory creation */ + if (!CreateDirectoryW (szProfilePath, NULL)) { - DPRINT1("AppendSystemPostfix() failed\n", GetLastError()); - return FALSE; - } + if (GetLastError() != ERROR_ALREADY_EXISTS) + { + DPRINT1("Error: %lu\n", GetLastError()); + return FALSE; + } + /* Directory existed, let's try to append the postfix */ + if (!AppendSystemPostfix(szBuffer, MAX_PATH)) + { + DPRINT1("AppendSystemPostfix() failed\n", GetLastError()); + RegCloseKey(hKey); + return FALSE; + } + /* Attempt again creation with appended postfix */ + wcscpy(szProfilePath, szProfilesPath); + wcscat(szProfilePath, L"\\"); + wcscat(szProfilePath, szBuffer); + if (!CreateDirectoryW(szProfilePath, NULL)) + { + if (GetLastError() != ERROR_ALREADY_EXISTS) + { + DPRINT1("Error: %lu\n", GetLastError()); + RegCloseKey(hKey); + return FALSE; + } + } + + } Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList", @@ -416,19 +466,6 @@ RegCloseKey(hKey); - /* Create 'All Users' profile directory */ - wcscpy(szProfilePath, szProfilesPath); - wcscat(szProfilePath, L"\\"); - wcscat(szProfilePath, szBuffer); - if (!CreateDirectoryW(szProfilePath, NULL)) - { - if (GetLastError() != ERROR_ALREADY_EXISTS) - { - DPRINT1("Error: %lu\n", GetLastError()); - return FALSE; - } - } - /* Set 'All Users' profile */ SetEnvironmentVariableW(L"ALLUSERSPROFILE", szProfilePath);