From: Vijay Kiran Kamuju infyquest@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47152 --- programs/schtasks/schtasks.c | 88 +++++++++++++++++++++++------- programs/schtasks/tests/schtasks.c | 35 +++++++++++- 2 files changed, 103 insertions(+), 20 deletions(-)
diff --git a/programs/schtasks/schtasks.c b/programs/schtasks/schtasks.c index 785552335d7..ae2ebee3193 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; @@ -204,15 +204,16 @@ static int create_command(int argc, WCHAR *argv[]) BOOL xml_mode = FALSE, tr_mode = FALSE;
while (argc) { + FIXME("args %s\n", wine_dbgstr_w(argv[0])); if (!wcsicmp(argv[0], L"/xml")) { - if (argc < 2) { + if (argc < 2 || !wcsncmp(argv[1], L"/", 1)){ FIXME("Missing /xml value\n"); - return 1; + return E_FAIL; }
if (xml_file) { FIXME("Duplicated /xml argument\n"); - return 1; + return E_FAIL; }
xml_file = argv[1]; @@ -220,46 +221,56 @@ static int create_command(int argc, WCHAR *argv[]) argc -= 2; argv += 2; } else if (!wcsicmp(argv[0], L"/tn")) { - if (argc < 2) { + if (argc < 2 || !wcsncmp(argv[1], L"/", 1)){ FIXME("Missing /tn value\n"); - return 1; + return E_FAIL; }
if (task_name) { FIXME("Duplicated /tn argument\n"); - return 1; + return E_FAIL; }
task_name = argv[1]; argc -= 2; argv += 2; } else if (!wcsicmp(argv[0], L"/tr")) { - if (argc < 2) { + if (argc < 2 || !wcsncmp(argv[1], L"/", 1)){ FIXME("Missing /tr value\n"); return 1; }
- FIXME("Unsupported /tr option %s\n", debugstr_w(argv[1])); + if (task_run) { + FIXME("Duplicated /tr argument\n"); + return E_FAIL; + } + + task_run = argv[1]; tr_mode = TRUE; argc -= 2; argv += 2; } else if (!wcsicmp(argv[0], L"/sc")) { - if (argc < 2) { + if (argc < 2 || !wcsncmp(argv[1], L"/", 1)){ FIXME("Missing /sc value\n"); - return 1; + return E_FAIL; }
- FIXME("Unsupported /sc option %s\n", debugstr_w(argv[1])); + if (schedule) { + FIXME("Duplicated /sc argument\n"); + return E_FAIL; + } + + schedule = argv[1]; tr_mode = TRUE; argc -= 2; argv += 2; } else if (!wcsicmp(argv[0], L"/rl")) { - if (argc < 2) { + if (argc < 2 || !wcsncmp(argv[1], L"/", 1)){ FIXME("Missing /rl value\n"); return 1; }
- FIXME("Unsupported /rl option %s\n", debugstr_w(argv[1])); + FIXME("Unsupported /rl option %s\n", debugstr_w(argv[0])); tr_mode = TRUE; argc -= 2; argv += 2; @@ -268,23 +279,23 @@ static int create_command(int argc, WCHAR *argv[]) argc--; argv++; } else if (!wcsicmp(argv[0], L"/ru")) { - if (argc < 2) { + if (argc < 2 || !wcsncmp(argv[1], L"/", 1)){ FIXME("Missing /ru value\n"); - return 1; + return E_FAIL; }
FIXME("Unsupported /ru option %s\n", debugstr_w(argv[1])); argc -= 2; argv += 2; - }else { + } else { FIXME("Unsupported argument %s\n", debugstr_w(argv[0])); - return 1; + return E_FAIL; } }
if (!task_name) { FIXME("Missing /tn argument\n"); - return 1; + return E_FAIL; }
if (xml_mode) { @@ -321,6 +332,45 @@ 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; + } + + FIXME("Unsupported /tr option %s\n", wine_dbgstr_w(task_run)); + 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", debugstr_w(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..70daa1e70be 100644 --- a/programs/schtasks/tests/schtasks.c +++ b/programs/schtasks/tests/schtasks.c @@ -245,9 +245,35 @@ START_TEST(schtasks)
create_file("test.xml", xml_a);
+ create_file("empty.xml", ""); + + r = run_command("schtasks /create /xml test.xml"); + ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ + + r = run_command("schtasks /create /xml test.xml /tn"); + ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ + + r = run_command("schtasks /create /xml /tn wine\winetest"); + ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ + + r = run_command("schtasks /create /xml test.xml /tn wine\winetest /tn"); + ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ + + r = run_command("schtasks /create /xml test.xml /tn wine\winetest /xml"); + ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ + + r = run_command("schtasks /create /xml test.xml /tn wine\winetest /tn test"); + ok(r == E_FAIL, "r = %lx\n", r); /* duplicate arguments */ + + r = run_command("schtasks /create /xml test.xml /tn wine\winetest /xml empty.xml"); + ok(r == E_FAIL, "r = %lx\n", r); /* duplicate arguments */ + r = run_command("schtasks /create /xml test.xml /tn wine\winetest"); ok(r == 0, "r = %lu\n", r);
+ r = run_command("schtasks /create /xml empty.xml /tn wine\winetest"); + ok(r == 1, "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);
@@ -269,6 +295,9 @@ START_TEST(schtasks) r = run_command("schtasks /create /tn wine\winetest"); ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */
+ r = run_command("schtasks /create /tn"); + ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */ + r = run_command("schtasks /create /tn wine\winetest /tr c:\windows\hh.exe"); ok(r == E_FAIL, "r = %lx\n", r); /* missing arguments */
@@ -276,16 +305,20 @@ 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);
+ r = DeleteFileA("empty.xml"); + ok(r, "DeleteFileA failed: %lu\n", GetLastError()); + r = DeleteFileA("test.xml"); ok(r, "DeleteFileA failed: %lu\n", GetLastError());
r = ITaskFolder_DeleteFolder(root, wine_testW, 0); ok(r == S_OK, "DeleteFolder(\wine\test) failed: %lx\n", r); + r = ITaskFolder_DeleteFolder(root, wineW, 0); ok(r == S_OK, "DeleteFolder(\wine) failed: %lx\n", r);