schtasks: Added support for /f argument in create command.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-01-22 17:35:55 +01:00 committed by Alexandre Julliard
parent 4415653f84
commit a6a5bca509
2 changed files with 9 additions and 1 deletions

View File

@ -183,6 +183,7 @@ static int create_command(int argc, WCHAR *argv[])
{
const WCHAR *task_name = NULL, *xml_file = NULL;
ITaskFolder *root = NULL;
LONG flags = TASK_CREATE;
IRegisteredTask *task;
VARIANT empty;
BSTR str, xml;
@ -217,6 +218,10 @@ static int create_command(int argc, WCHAR *argv[])
task_name = argv[1];
argc -= 2;
argv += 2;
}else if(!strcmpiW(argv[0], f_optW)) {
flags = TASK_CREATE_OR_UPDATE;
argc--;
argv++;
}else {
FIXME("Unsupported argument %s\n", debugstr_w(argv[0]));
return 1;
@ -245,7 +250,7 @@ static int create_command(int argc, WCHAR *argv[])
V_VT(&empty) = VT_EMPTY;
str = SysAllocString(task_name);
hres = ITaskFolder_RegisterTask(root, str, xml, TASK_CREATE, empty, empty,
hres = ITaskFolder_RegisterTask(root, str, xml, flags, empty, empty,
TASK_LOGON_NONE, empty, &task);
SysFreeString(str);
SysFreeString(xml);

View File

@ -211,6 +211,9 @@ START_TEST(schtasks)
r = run_command("schtasks /change /tn wine\\winetest /enable");
ok(r == 0, "r = %u\n", r);
r = run_command("schtasks /create /xml test.xml /f /tn wine\\winetest");
ok(r == 0, "r = %u\n", r); /* task already exists, but /f argument provided */
r = run_command("schtasks /create /xml test.xml /tn wine\\winetest");
ok(r == 1, "r = %u\n", r); /* task already exists */