msi: Register service arguments in the InstallServices action.

This commit is contained in:
Hans Leidekker 2010-10-22 10:37:02 +02:00 committed by Alexandre Julliard
parent 7f5204e1bc
commit 031c70c965
2 changed files with 20 additions and 6 deletions

View File

@ -5369,9 +5369,8 @@ static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
SC_HANDLE hscm, service = NULL;
LPCWSTR comp, key;
LPWSTR name = NULL, disp = NULL, load_order = NULL, serv_name = NULL;
LPWSTR depends = NULL, pass = NULL;
DWORD serv_type, start_type;
DWORD err_control;
LPWSTR depends = NULL, pass = NULL, args = NULL, image_path = NULL;
DWORD serv_type, start_type, err_control;
SERVICE_DESCRIPTIONW sd = {NULL};
static const WCHAR query[] =
@ -5400,6 +5399,7 @@ static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
deformat_string(package, MSI_RecordGetString(rec, 8), &depends);
deformat_string(package, MSI_RecordGetString(rec, 9), &serv_name);
deformat_string(package, MSI_RecordGetString(rec, 10), &pass);
deformat_string(package, MSI_RecordGetString(rec, 11), &args);
comp = MSI_RecordGetString(rec, 12);
deformat_string(package, MSI_RecordGetString(rec, 13), &sd.lpDescription);
@ -5420,9 +5420,21 @@ static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
goto done;
}
if (!args || !args[0]) image_path = file->TargetPath;
else
{
int len = strlenW(file->TargetPath) + strlenW(args) + 2;
if (!(image_path = msi_alloc(len * sizeof(WCHAR))))
return ERROR_OUTOFMEMORY;
strcpyW(image_path, file->TargetPath);
strcatW(image_path, szSpace);
strcatW(image_path, args);
}
service = CreateServiceW(hscm, name, disp, GENERIC_ALL, serv_type,
start_type, err_control, file->TargetPath,
load_order, NULL, depends, serv_name, pass);
start_type, err_control, image_path, load_order,
NULL, depends, serv_name, pass);
if (!service)
{
if (GetLastError() != ERROR_SERVICE_EXISTS)
@ -5434,6 +5446,7 @@ static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
WARN("failed to set service description %u\n", GetLastError());
}
if (image_path != file->TargetPath) msi_free(image_path);
done:
CloseServiceHandle(service);
CloseServiceHandle(hscm);
@ -5444,6 +5457,7 @@ done:
msi_free(serv_name);
msi_free(pass);
msi_free(depends);
msi_free(args);
return ERROR_SUCCESS;
}

View File

@ -212,7 +212,7 @@ static const char service_install_dat[] =
"LoadOrderGroup\tDependencies\tStartName\tPassword\tArguments\tComponent_\tDescription\n"
"s72\ts255\tL255\ti4\ti4\ti4\tS255\tS255\tS255\tS255\tS255\ts72\tL255\n"
"ServiceInstall\tServiceInstall\n"
"TestService\t[SERVNAME]\t[SERVDISP]\t2\t3\t0\t\t\tTestService\t\t\tservice_comp\t\t";
"TestService\t[SERVNAME]\t[SERVDISP]\t2\t3\t0\t\tservice1[~]+group1[~]service2[~]+group2[~][~]\tTestService\t\t-a arg\tservice_comp\tdescription";
static const char service_control_dat[] =
"ServiceControl\tName\tEvent\tArguments\tWait\tComponent_\n"