mirror of
https://github.com/reactos/reactos.git
synced 2024-05-15 09:41:59 +00:00
[SYSSETUP] Add new Env section to unattend.inf
This allows to add environment variables during unattended setup
This commit is contained in:
parent
62d7486ef6
commit
d4e38a630f
|
@ -74,3 +74,8 @@ ProductOption = 0
|
|||
; XResolution = 1440
|
||||
; YResolution = 900
|
||||
; VRefresh = 0
|
||||
|
||||
; enable this section to add environment variables
|
||||
;[Env]
|
||||
;WINETEST_PLATFORM=reactos
|
||||
|
||||
|
|
|
@ -2831,6 +2831,53 @@ ProcessUnattendSection(
|
|||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if (SetupFindFirstLineW(pSetupData->hSetupInf,
|
||||
L"Env",
|
||||
NULL,
|
||||
&InfContext))
|
||||
{
|
||||
if (RegCreateKeyExW(
|
||||
HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ, NULL, &hKey, NULL) != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1("Error: failed to open HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\n");
|
||||
return;
|
||||
}
|
||||
do
|
||||
{
|
||||
if (!SetupGetStringFieldW(&InfContext,
|
||||
0,
|
||||
szName,
|
||||
ARRAYSIZE(szName),
|
||||
&LineLength))
|
||||
{
|
||||
DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SetupGetStringFieldW(&InfContext,
|
||||
1,
|
||||
szValue,
|
||||
ARRAYSIZE(szValue),
|
||||
&LineLength))
|
||||
{
|
||||
DPRINT1("Error: SetupGetStringField failed with %d\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
DPRINT1("[ENV] %S=%S\n", szName, szValue);
|
||||
|
||||
DWORD dwType = wcschr(szValue, '%') != NULL ? REG_EXPAND_SZ : REG_SZ;
|
||||
|
||||
if (RegSetValueExW(hKey, szName, 0, dwType, (const BYTE*)szValue, (DWORD)(wcslen(szValue) + 1) * sizeof(TCHAR)) != ERROR_SUCCESS)
|
||||
{
|
||||
DPRINT1(" - Error %d\n", GetLastError());
|
||||
}
|
||||
|
||||
} while (SetupFindNextLine(&InfContext, &InfContext));
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
|
|
Loading…
Reference in a new issue