Scheduler warning

This commit is contained in:
seerge
2023-03-13 12:10:29 +01:00
parent b46f0fb887
commit a7e8ba3241
2 changed files with 13 additions and 4 deletions

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.24</AssemblyVersion>
<AssemblyVersion>0.25</AssemblyVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -22,16 +22,25 @@ public class Startup
var userId = WindowsIdentity.GetCurrent().Name;
Debug.WriteLine(strExeFilePath);
TaskDefinition td = TaskService.Instance.NewTask();
td.RegistrationInfo.Description = "GHelper Auto Start";
td.Triggers.Add(new LogonTrigger { UserId = userId, });
td.Triggers.Add(new LogonTrigger { UserId = userId });
td.Actions.Add(strExeFilePath);
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
Debug.WriteLine(strExeFilePath);
Debug.WriteLine(userId);
try
{
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
} catch
{
MessageBox.Show("Can't schedule task", "Scheduler Error", MessageBoxButtons.OK);
}
}
public static void UnSchedule()