Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: Create daily 9h Task Schedule in Windows 7

$
0
0
Hi guys,

I am trying to create a schedule task at the installation time on a Windows 7 32bits, but there is something wrong because it returns me an exception "LogonType". Another thing, I want to create a schedule to run every day at 9h morning.

Can you help me out on this one? What is missing?!

This is the code that I am using:
using (TaskService ts = new TaskService())
                {
                    TaskDefinition td = ts.NewTask();
                    td.RegistrationInfo.Description = "Daily trigger";
                    td.Principal.LogonType = TaskLogonType.InteractiveToken;
                    
                    DailyTrigger dt = new DailyTrigger();
                    dt.Repetition.Duration = TimeSpan.FromHours(9); // is this ok to run every day at 9h?????
                    td.Triggers.Add(dt);


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

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

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>