From 7e1d317368a5675a7cbba2100eb913417324a12b Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sun, 12 Nov 2017 18:59:13 +0100 Subject: [PATCH] Autorun task privilage fixes --- Artemis/Artemis/Resources/Artemis autorun.xml | Bin 3228 -> 3228 bytes Artemis/Artemis/Settings/GeneralSettings.cs | 14 +++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Artemis/Artemis/Resources/Artemis autorun.xml b/Artemis/Artemis/Resources/Artemis autorun.xml index cd46cbf98c499c3eed04c6c03cfd95c43f456198..c9991277b70699c229af06793bb5249125ed3d07 100644 GIT binary patch delta 37 tcmbOuIY)BC97f@4hH8dHhEj$Sh75*$h9ZVqhT6?*8J(Fne_~$60RYhP3r+w4 delta 37 tcmbOuIY)BC97e%lh609shD?S$hHQpP20sR$&FdMRnHUu|e`H?G0RY9~3UdGe diff --git a/Artemis/Artemis/Settings/GeneralSettings.cs b/Artemis/Artemis/Settings/GeneralSettings.cs index e4883c874..e627ff0a2 100644 --- a/Artemis/Artemis/Settings/GeneralSettings.cs +++ b/Artemis/Artemis/Settings/GeneralSettings.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.IO; +using System.Web.Security; using System.Windows; using Artemis.DAL; using Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing; @@ -132,10 +133,17 @@ namespace Artemis.Settings { // Overwrite any existing tasks in case the installation folder changed var path = Path.GetTempFileName(); - var xml = Resources.Artemis_autorun.Replace("{{executablePath}}", mgr.RootAppDirectory + "\\Update.exe"); - + var xml = Resources.Artemis_autorun + .Replace("{{executablePath}}", mgr.RootAppDirectory + "\\Update.exe") + .Replace("{{author}}", System.Security.Principal.WindowsIdentity.GetCurrent().Name); File.WriteAllText(path, xml); - ts.RootFolder.ImportTask(null, path); + + var task = ts.RootFolder.ImportTask(null, path); + task.Definition.Principal.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name; + task.Definition.Principal.LogonType = TaskLogonType.InteractiveToken; + task.Definition.Principal.RunLevel = TaskRunLevel.Highest; + task.RegisterChanges(); + File.Delete(path); } else if (existing != null)