Blaze
Blaze

Reputation: 1933

How to make exe run as scheduled task

I created a WinForm project in c# and added a code file called Loader.cs. In that file I have a method called LoadData(). I deleted the default "Form1" from the project changed the logic in the Main() to run the LoadData() method. This all works when run in my VS2008 IDE. I then built as Release and moved the resulting .exe to a different machine and set up a Scheduled Task with the trigger every hour and the action pointing to the .exe with /Auto as an argument. The task does nothing, just sits running and is not doing any of the processing. I have to eventually end the task. Same if run manually. If I double click the exe from the folder where it's located it does nothing. How can I get this exe to run as Scheduled Task or even just run independently?

In Program.cs:

static class Program
{
    [STAThread]
    static void Main()
    {
        Loader lc = new Loader();
        lc.LoadData();
    }
}

And in the Loader.cs file:

    public void LoadData()
{
   // ...processing
}

Upvotes: 1

Views: 954

Answers (1)

Mr. B
Mr. B

Reputation: 2985

I would try putting try { } catch { } in your main and examining the Exception.

Upvotes: 1

Related Questions