msi: Set or override a user environment string when there is no prefix.
This commit is contained in:
parent
d13b2b658e
commit
659768e203
@ -5313,8 +5313,7 @@ static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags )
|
||||
}
|
||||
}
|
||||
|
||||
if (!*flags ||
|
||||
check_flag_combo(*flags, ENV_ACT_SETALWAYS | ENV_ACT_SETABSENT) ||
|
||||
if (check_flag_combo(*flags, ENV_ACT_SETALWAYS | ENV_ACT_SETABSENT) ||
|
||||
check_flag_combo(*flags, ENV_ACT_REMOVEMATCH | ENV_ACT_SETABSENT) ||
|
||||
check_flag_combo(*flags, ENV_ACT_REMOVEMATCH | ENV_ACT_SETALWAYS) ||
|
||||
check_flag_combo(*flags, ENV_ACT_SETABSENT | ENV_MOD_MASK))
|
||||
@ -5323,6 +5322,9 @@ static LONG env_set_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags )
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
if (!*flags)
|
||||
*flags = ENV_ACT_SETALWAYS | ENV_ACT_REMOVE;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
@ -5350,6 +5352,8 @@ static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param )
|
||||
name = MSI_RecordGetString(rec, 2);
|
||||
value = MSI_RecordGetString(rec, 3);
|
||||
|
||||
TRACE("name %s value %s\n", debugstr_w(name), debugstr_w(value));
|
||||
|
||||
res = env_set_flags(&name, &value, &flags);
|
||||
if (res != ERROR_SUCCESS)
|
||||
goto done;
|
||||
|
@ -124,6 +124,7 @@ static const CHAR install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
|
||||
"MoveFiles\t\t1700\n"
|
||||
"InstallFiles\t\t4000\n"
|
||||
"DuplicateFiles\t\t4500\n"
|
||||
"WriteEnvironmentStrings\t\t4550\n"
|
||||
"CreateShortcuts\t\t4600\n"
|
||||
"InstallServices\t\t5000\n"
|
||||
"InstallFinalize\t\t6600\n"
|
||||
@ -165,6 +166,15 @@ static const CHAR shortcut_dat[] = "Shortcut\tDirectory_\tName\tComponent_\tTarg
|
||||
"Shortcut\tShortcut\n"
|
||||
"Shortcut\tMSITESTDIR\tShortcut\tcomponent\tShortcut\t\tShortcut\t\t\t\t\t\n";
|
||||
|
||||
static const CHAR environment_dat[] = "Environment\tName\tValue\tComponent_\n"
|
||||
"s72\tl255\tL255\ts72\n"
|
||||
"Environment\tEnvironment\n"
|
||||
"Var1\t=-MSITESTVAR1\t1\tOne\n"
|
||||
"Var2\tMSITESTVAR2\t1\tOne\n"
|
||||
"Var3\t=-MSITESTVAR3\t1\tOne\n"
|
||||
"Var4\tMSITESTVAR4\t1\tOne\n";
|
||||
|
||||
|
||||
static const CHAR up_property_dat[] = "Property\tValue\n"
|
||||
"s72\tl0\n"
|
||||
"Property\tProperty\n"
|
||||
@ -904,6 +914,19 @@ static const msi_table sc_tables[] =
|
||||
ADD_TABLE(shortcut)
|
||||
};
|
||||
|
||||
static const msi_table env_tables[] =
|
||||
{
|
||||
ADD_TABLE(component),
|
||||
ADD_TABLE(directory),
|
||||
ADD_TABLE(feature),
|
||||
ADD_TABLE(feature_comp),
|
||||
ADD_TABLE(file),
|
||||
ADD_TABLE(install_exec_seq),
|
||||
ADD_TABLE(media),
|
||||
ADD_TABLE(property),
|
||||
ADD_TABLE(environment)
|
||||
};
|
||||
|
||||
static const msi_table up_tables[] =
|
||||
{
|
||||
ADD_TABLE(component),
|
||||
@ -6240,6 +6263,74 @@ static void test_shortcut(void)
|
||||
delete_test_files();
|
||||
}
|
||||
|
||||
static void test_envvar(void)
|
||||
{
|
||||
UINT r;
|
||||
HKEY env;
|
||||
LONG res;
|
||||
DWORD type, size;
|
||||
char buffer[16];
|
||||
|
||||
create_test_files();
|
||||
create_database(msifile, env_tables, sizeof(env_tables) / sizeof(msi_table));
|
||||
|
||||
res = RegCreateKeyExA(HKEY_CURRENT_USER, "Environment", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &env, NULL);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
res = RegSetValueExA(env, "MSITESTVAR1", 0, REG_SZ, (const BYTE *)"0", 2);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
res = RegSetValueExA(env, "MSITESTVAR2", 0, REG_SZ, (const BYTE *)"0", 2);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
r = MsiInstallProductA(msifile, NULL);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
|
||||
|
||||
type = REG_NONE;
|
||||
size = sizeof(buffer);
|
||||
buffer[0] = 0;
|
||||
res = RegQueryValueExA(env, "MSITESTVAR1", NULL, &type, (LPBYTE)buffer, &size);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
|
||||
ok(!lstrcmp(buffer, "1"), "Expected \"1\", got %s\n", buffer);
|
||||
|
||||
res = RegDeleteValueA(env, "MSITESTVAR1");
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
type = REG_NONE;
|
||||
size = sizeof(buffer);
|
||||
buffer[0] = 0;
|
||||
res = RegQueryValueExA(env, "MSITESTVAR2", NULL, &type, (LPBYTE)buffer, &size);
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
|
||||
ok(!lstrcmp(buffer, "1"), "Expected \"1\", got %s\n", buffer);
|
||||
|
||||
res = RegDeleteValueA(env, "MSITESTVAR2");
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
res = RegDeleteValueA(env, "MSITESTVAR3");
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
res = RegDeleteValueA(env, "MSITESTVAR4");
|
||||
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
|
||||
|
||||
RegCloseKey(env);
|
||||
|
||||
delete_pf("msitest\\cabout\\new\\five.txt", TRUE);
|
||||
delete_pf("msitest\\cabout\\new", FALSE);
|
||||
delete_pf("msitest\\cabout\\four.txt", TRUE);
|
||||
delete_pf("msitest\\cabout", FALSE);
|
||||
delete_pf("msitest\\changed\\three.txt", TRUE);
|
||||
delete_pf("msitest\\changed", FALSE);
|
||||
delete_pf("msitest\\first\\two.txt", TRUE);
|
||||
delete_pf("msitest\\first", FALSE);
|
||||
delete_pf("msitest\\filename", TRUE);
|
||||
delete_pf("msitest\\one.txt", TRUE);
|
||||
delete_pf("msitest\\service.exe", TRUE);
|
||||
delete_pf("msitest", FALSE);
|
||||
delete_test_files();
|
||||
}
|
||||
|
||||
START_TEST(install)
|
||||
{
|
||||
DWORD len;
|
||||
@ -6322,6 +6413,7 @@ START_TEST(install)
|
||||
test_propcase();
|
||||
test_int_widths();
|
||||
test_shortcut();
|
||||
test_envvar();
|
||||
|
||||
DeleteFileA(log_file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user