diff --git a/GHelper.csproj b/GHelper.csproj index ed4be555..c54162c7 100644 --- a/GHelper.csproj +++ b/GHelper.csproj @@ -16,7 +16,7 @@ x64 False True - 0.24 + 0.25 diff --git a/Startup.cs b/Startup.cs index 597ced1d..d610427e 100644 --- a/Startup.cs +++ b/Startup.cs @@ -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()