Trying to run the scheduler from a system service, as the idea is to start an executable, yet by some reason it doesnt create a new task:
The local username is "Sun", and the computer name is "Sun-PC"
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "ObeserverGuard";
// Create an action that will launch Notepad whenever the trigger fires
td.Actions.Add(new ExecAction( "notepad.exe", "test.log", null ) );
ts.RootFolder.RegisterTaskDefinition( @"G:\Projects\Elx\Service\ObserverService\ObserverService\bin\Debug\", td, TaskCreation.CreateOrUpdate, "Sun", "", TaskLogonType.InteractiveToken );
ts.Execute( "notepad.exe" )
.Once()
.Starting( DateTime.Now.AddSeconds( 1 ) )
.AsTask( "ObeserverGuard" );
}
Trying to run the scheduler from a system service, as the idea is to start an executable, yet by some reason it doesnt create a new task: The local username is "Sun", and the computer name is "Sun-PC"