2012-04-26 14 views
0

30分ごとに実行したいコードがあります。 Windowsタスクスケジューラ - >タスクの作成 - >アクション - >新規 - スクリプト/プログラムを挿入する場所があります。 質問私のプログラムを追加するためにどのようなプロジェクトを作成する必要がありますか、どのような種類のファイルを追加する必要がありますか?WindowsのタスクスケジューラでC#プログラムをスケジュールする

30分ごとに実行したいのは、ネットから何かを取得して処理し、dbに挿入する30行のコードです。

ありがとうございました。

+0

、私はそれがexeファイルもことができますね。.. – Nir

答えて

3

タスクスケジューラは通常のEXEを実行します。

特別な操作は必要ありません。 EXEが実行されなく見えるように、あなたが例えばWinフォームアプリケーションをトリガーする場合は、」勝ったということを念頭に置い

私は本当にそれが何であるかを気にいけない
+1

しかしクマフォームを参照してください。 – Dan

+2

@ダン:それはどのユーザーがタスクを設定するかによって異なります。 – SLaks

3
using System; 
    using Microsoft.Win32.TaskScheduler; 

    class Program 
    { 
    static void Main(string[] args) 
    { 
    // Get the service on the local machine 

    using (TaskService ts = new TaskService()) 
    { 

    // Create a new task definition and assign properties 
     TaskDefinition td = ts.NewTask(); 
     td.RegistrationInfo.Description = "Does something"; 

     // Create a trigger that will fire the task at this time every other day 
     td.Triggers.Add(new DailyTrigger { DaysInterval = 2 }); 

     // Create an action that will launch Notepad whenever the trigger fires 
     td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null)); 

     // Register the task in the root folder 
     ts.RootFolder.RegisterTaskDefinition(@"Test", td); 

     // Remove the task we just created 
     ts.RootFolder.DeleteTask("Test"); 
     } 
    } 
    } 
関連する問題