digitalmars.D.learn - D program in Windows Task Scheduler.
Hi All, I have small D program which run's perfectly when i run it manually, but when I schedule the same via windows task scheduler and choose the option "Run whether user is logged on or not" the program does not execute, the task scheduler job log return code 4294967295(Invalid argument). SO request you help on this. Execution Steps test.exe <option> Option: run , dryrun ,help Example Execution : test.exe dryrun Program: import std.stdio; import std.getopt; import std.path; import core.stdc.stdlib: exit; void Test1(string Step) { writeln("This is Test1 :", Step); } void Test2() { writeln("This is Test2"); } void Test3() { writeln("This is Help"); } void main (string[] args) { if (args.length <= 1 || args.length > 2 ) { writeln("No Arguments Provided"); exit(-1); } string op = args[1]; try { getopt(args, std.getopt.config.caseInsensitive, std.getopt.config.stopOnFirstNonOption); switch (op) { case "dryrun" , "run" : auto Step = op; Test1(Step); Test2; break; case "help" : Test3; break; default : writefln("Unknown operation"); } } catch (Exception exc) { writefln("Error processing command line arguments: %s", exc.msg);} } From, Vino.B
Nov 28 2017
On Tue, 28 Nov 2017 09:44:39 +0000, Vino wrote:Hi All, I have small D program which run's perfectly when i run it manually, but when I schedule the same via windows task scheduler and choose the option "Run whether user is logged on or not" the program does not execute, the task scheduler job log return code 4294967295(Invalid argument). SO request you help on this.You're not using getopt in the sample; if you comment that line out, do you still have the problem? How are you passing arguments in Task Scheduler? You should be using the textbox for arguments, not the same one the application is passed in. Program/script: test.exe Add arguments: dryrun, run If that's correct, create a batch file that takes no arguments and calls your application and try running the batch file via Task Scheduler. If that fails, the application is probably trying to do something it doesn't have permission to do. If it succeeds, the task command is probably not set up correctly. --Ryan
Nov 28 2017