[PATCH v4 0/2] MR5151: schtasks: Ignore /tr /sc /rl options in create command.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47152 This is initial part which ignores the options. -- v4: schtasks: Stub implementation of /sc option in create command. schtasks: Ignore /tr /sc /rl options in create command. https://gitlab.winehq.org/wine/wine/-/merge_requests/5151
From: Vijay Kiran Kamuju <infyquest(a)gmail.com> --- programs/schtasks/schtasks.c | 84 ++++++++++++++++++++++-------- programs/schtasks/tests/schtasks.c | 22 +++++++- 2 files changed, 82 insertions(+), 24 deletions(-) diff --git a/programs/schtasks/schtasks.c b/programs/schtasks/schtasks.c index c9434801db8..785552335d7 100644 --- a/programs/schtasks/schtasks.c +++ b/programs/schtasks/schtasks.c @@ -201,6 +201,7 @@ static int create_command(int argc, WCHAR *argv[]) VARIANT empty; BSTR str, xml; HRESULT hres; + BOOL xml_mode = FALSE, tr_mode = FALSE; while (argc) { if (!wcsicmp(argv[0], L"/xml")) { @@ -215,6 +216,7 @@ static int create_command(int argc, WCHAR *argv[]) } xml_file = argv[1]; + xml_mode = TRUE; argc -= 2; argv += 2; } else if (!wcsicmp(argv[0], L"/tn")) { @@ -231,6 +233,36 @@ static int create_command(int argc, WCHAR *argv[]) task_name = argv[1]; argc -= 2; argv += 2; + } else if (!wcsicmp(argv[0], L"/tr")) { + if (argc < 2) { + FIXME("Missing /tr value\n"); + return 1; + } + + FIXME("Unsupported /tr option %s\n", debugstr_w(argv[1])); + tr_mode = TRUE; + argc -= 2; + argv += 2; + } else if (!wcsicmp(argv[0], L"/sc")) { + if (argc < 2) { + FIXME("Missing /sc value\n"); + return 1; + } + + FIXME("Unsupported /sc option %s\n", debugstr_w(argv[1])); + tr_mode = TRUE; + argc -= 2; + argv += 2; + } else if (!wcsicmp(argv[0], L"/rl")) { + if (argc < 2) { + FIXME("Missing /rl value\n"); + return 1; + } + + FIXME("Unsupported /rl option %s\n", debugstr_w(argv[1])); + tr_mode = TRUE; + argc -= 2; + argv += 2; } else if (!wcsicmp(argv[0], L"/f")) { flags = TASK_CREATE_OR_UPDATE; argc--; @@ -255,33 +287,41 @@ static int create_command(int argc, WCHAR *argv[]) return 1; } - if (!xml_file) { - FIXME("Missing /xml argument\n"); - return E_FAIL; - } + if (xml_mode) { + if (tr_mode) { + FIXME("/xml option can only be used with /ru /f /tn\n"); + return E_FAIL; + } - xml = read_file_to_bstr(xml_file); - if (!xml) - return 1; + if (!xml_file) { + FIXME("Missing /xml argument\n"); + return E_FAIL; + } - root = get_tasks_root_folder(); - if (!root) { - SysFreeString(xml); - return 1; - } + xml = read_file_to_bstr(xml_file); + if (!xml) + return 1; - V_VT(&empty) = VT_EMPTY; - str = SysAllocString(task_name); - hres = ITaskFolder_RegisterTask(root, str, xml, flags, empty, empty, + root = get_tasks_root_folder(); + if (!root) { + SysFreeString(xml); + return 1; + } + + V_VT(&empty) = VT_EMPTY; + str = SysAllocString(task_name); + hres = ITaskFolder_RegisterTask(root, str, xml, flags, empty, empty, TASK_LOGON_NONE, empty, &task); - SysFreeString(str); - SysFreeString(xml); - ITaskFolder_Release(root); - if (FAILED(hres)) - return 1; + SysFreeString(str); + SysFreeString(xml); + ITaskFolder_Release(root); + if (FAILED(hres)) + return 1; - IRegisteredTask_Release(task); - return 0; + IRegisteredTask_Release(task); + return 0; + } + return E_FAIL; } static int delete_command(int argc, WCHAR *argv[]) diff --git a/programs/schtasks/tests/schtasks.c b/programs/schtasks/tests/schtasks.c index 3ed2378c90c..dd7d331f368 100644 --- a/programs/schtasks/tests/schtasks.c +++ b/programs/schtasks/tests/schtasks.c @@ -248,20 +248,38 @@ START_TEST(schtasks) r = run_command("schtasks /create /xml test.xml /tn wine\\winetest"); ok(r == 0, "r = %lu\n", r); + r = run_command("schtasks /create /xml test.xml /tn wine\\winetest /tr c:\\windows\\hh.exe"); + ok(r == E_FAIL, "r = %lu\n", r); + r = run_command("schtasks /change /tn wine\\winetest /enable"); ok(r == 0, "r = %lu\n", r); r = run_command("schtasks /create /xml test.xml /f /tn wine\\winetest"); ok(r == 0, "r = %lu\n", r); /* task already exists, but /f argument provided */ + r = run_command("schtasks /create /xml test.xml /f /tn wine\\winetest /tr c:\\windows\\hh.exe"); + ok(r == E_FAIL, "r = %lu\n", r); /* task already exists, but /f argument provided */ + r = run_command("schtasks /create /xml test.xml /tn wine\\winetest"); ok(r == 1, "r = %lu\n", r); /* task already exists */ + r = run_command("schtasks /Delete /f /tn wine\\winetest"); + ok(r == 0, "r = %lu\n", r); + r = run_command("schtasks /create /tn wine\\winetest"); ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ - r = run_command("schtasks /Delete /f /tn wine\\winetest"); - ok(r == 0, "r = %lu\n", r); + r = run_command("schtasks /create /tn wine\\winetest /tr c:\\windows\\hh.exe"); + ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ + + r = run_command("schtasks /create /tn wine\\winetest /tr c:\\windows\\hh.exe /sc wine"); + ok(r == E_FAIL, "r = %lx\n", r); /* invalid schedule */ + + r = run_command("schtasks /create /tn wine\\winetest /tr c:\\windows\\hh.exe /sc daily"); + todo_wine ok(r == 0, "r = %lx\n", r); /* daily schedule */ + + r = run_command("schtasks /DELETE /f /tn wine\\winetest"); + todo_wine ok(r == 0, "r = %lu\n", r); r = DeleteFileA("test.xml"); ok(r, "DeleteFileA failed: %lu\n", GetLastError()); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5151
From: Vijay Kiran Kamuju <infyquest(a)gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47152 --- programs/schtasks/schtasks.c | 43 ++++++++++++++++++++++++++++-- programs/schtasks/tests/schtasks.c | 2 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/programs/schtasks/schtasks.c b/programs/schtasks/schtasks.c index 785552335d7..68b58c44511 100644 --- a/programs/schtasks/schtasks.c +++ b/programs/schtasks/schtasks.c @@ -194,7 +194,7 @@ static int change_command(int argc, WCHAR *argv[]) static int create_command(int argc, WCHAR *argv[]) { - const WCHAR *task_name = NULL, *xml_file = NULL; + const WCHAR *task_name = NULL, *xml_file = NULL, *task_run = NULL, *schedule = NULL; ITaskFolder *root = NULL; LONG flags = TASK_CREATE; IRegisteredTask *task; @@ -240,6 +240,7 @@ static int create_command(int argc, WCHAR *argv[]) } FIXME("Unsupported /tr option %s\n", debugstr_w(argv[1])); + task_run = argv[1]; tr_mode = TRUE; argc -= 2; argv += 2; @@ -249,7 +250,7 @@ static int create_command(int argc, WCHAR *argv[]) return 1; } - FIXME("Unsupported /sc option %s\n", debugstr_w(argv[1])); + schedule = argv[1]; tr_mode = TRUE; argc -= 2; argv += 2; @@ -321,6 +322,44 @@ static int create_command(int argc, WCHAR *argv[]) IRegisteredTask_Release(task); return 0; } + + if (tr_mode) { + if (!task_run) { + FIXME("Missing /tr argument\n"); + return E_FAIL; + } + + if (!schedule) { + FIXME("Missing /sc argument\n"); + return E_FAIL; + } else if (!wcsicmp(schedule, L"minute")){ + FIXME("Unsupported /sc minute\n"); + } else if (!wcsicmp(schedule, L"hourly")){ + FIXME("Unsupported /sc hourly\n"); + } else if (!wcsicmp(schedule, L"daily")){ + FIXME("Unsupported /sc daily\n"); + } else if (!wcsicmp(schedule, L"weekly")){ + FIXME("Unsupported /sc weekly\n"); + } else if (!wcsicmp(schedule, L"monthly")){ + FIXME("Unsupported /sc monthly\n"); + } else if (!wcsicmp(schedule, L"once")){ + FIXME("Unsupported /sc once\n"); + } else if (!wcsicmp(schedule, L"onstart")){ + FIXME("Unsupported /sc onstart\n"); + } else if (!wcsicmp(schedule, L"onlogon")){ + FIXME("Unsupported /sc onlogon\n"); + } else if (!wcsicmp(schedule, L"onidle")){ + FIXME("Unsupported /sc onidle\n"); + } else if (!wcsicmp(schedule, L"onevent")){ + FIXME("Unsupported /sc onevent\n"); + } else { + FIXME("Invalid schedule type %s\n", schedule); + return E_FAIL; + } + + return 0; + } + return E_FAIL; } diff --git a/programs/schtasks/tests/schtasks.c b/programs/schtasks/tests/schtasks.c index dd7d331f368..f58a89854bb 100644 --- a/programs/schtasks/tests/schtasks.c +++ b/programs/schtasks/tests/schtasks.c @@ -276,7 +276,7 @@ START_TEST(schtasks) ok(r == E_FAIL, "r = %lx\n", r); /* invalid schedule */ r = run_command("schtasks /create /tn wine\\winetest /tr c:\\windows\\hh.exe /sc daily"); - todo_wine ok(r == 0, "r = %lx\n", r); /* daily schedule */ + ok(r == 0, "r = %lx\n", r); /* daily schedule */ r = run_command("schtasks /DELETE /f /tn wine\\winetest"); todo_wine ok(r == 0, "r = %lu\n", r); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5151
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=143393 Your paranoid android. === debian11b (64 bit WoW report) === Report validation errors: shell32:shlfolder crashed (c0000005)
participants (3)
-
Marvin -
Vijay Kiran Kamuju -
Vijay Kiran Kamuju (@infyquest)