I'm trying to implement a way for me to start my WPF application with specific arguments through the Windows task schedular and CMD. I've added the code below.
protected override void OnStartup(StartupEventArgs e)
{
Logger.Info(e.Args.Length);
for (int i = 0; i != e.Args.Length; ++i)
{
if (e.Args[i] == "test")
{
Logger.Info($"G");
}
else
{
Logger.Info($"B");
}
}
}
When I start publish the application and start it through CMD or schedule it in task schedular with arguments, the e.Args.Length
is 0. But when I add an argument in Properties > Debug > Command line arguments
, it does work.
Any idea what I'm missing?