EDN Admin
Well-known member
Hi,
I want to create a schedule task in C# that will run an exe.
Code as follows, being run an administrator :
<pre class="prettyprint Win32_ScheduledJobClass = new ManagementClass(@"Win32_ScheduledJob");
ManagementBaseObject createParameters = Win32_ScheduledJobClass.GetMethodParameters("Create");
createParameters["Command"] = mCommand;
createParameters["DaysOfMonth"] = daysOfMonth;
createParameters["DaysOfWeek"] = daysOfWeek;
createParameters["InteractWithDesktop"] = interactWithDesktop ;
createParameters["RunRepeatedly"] = mRunRepeatedly ;
createParameters["StartTime"] = formatString ;
Win32_ScheduledJobClass.InvokeMethod("Create", createParameters,null);[/code]
I get the Accepted return code.
I have tried the Command property inside " " as there is a space in the path ( Command exe on same machine as code that created the ScheduledJob ). I have run the at command in cmd and it is present and set with start time that I expected.
Is it because it is a 64 bit machine ?
Are any credentials required ?
Should there be an entry in the Event Log ?
Is there a wmi event that can be watched ?
The Task Scheduler service is running.
Many thanks
Tony
<br/>
<br/>
<br/>
View the full article
I want to create a schedule task in C# that will run an exe.
Code as follows, being run an administrator :
<pre class="prettyprint Win32_ScheduledJobClass = new ManagementClass(@"Win32_ScheduledJob");
ManagementBaseObject createParameters = Win32_ScheduledJobClass.GetMethodParameters("Create");
createParameters["Command"] = mCommand;
createParameters["DaysOfMonth"] = daysOfMonth;
createParameters["DaysOfWeek"] = daysOfWeek;
createParameters["InteractWithDesktop"] = interactWithDesktop ;
createParameters["RunRepeatedly"] = mRunRepeatedly ;
createParameters["StartTime"] = formatString ;
Win32_ScheduledJobClass.InvokeMethod("Create", createParameters,null);[/code]
I get the Accepted return code.
I have tried the Command property inside " " as there is a space in the path ( Command exe on same machine as code that created the ScheduledJob ). I have run the at command in cmd and it is present and set with start time that I expected.
Is it because it is a 64 bit machine ?
Are any credentials required ?
Should there be an entry in the Event Log ?
Is there a wmi event that can be watched ?
The Task Scheduler service is running.
Many thanks
Tony
<br/>
<br/>
<br/>
View the full article