question

IntelliSense-8139 avatar image
0 Votes"
IntelliSense-8139 asked SeeyaXi-msft edited

How can I run a schedule task from UWP app on Windows 10 iot Core?

System: Windows 10 IoT Core (10.0.17763.1577)

Request: I would like to run a task from UWP app with ProcessLauncher.RunToCompletionAsync method.

Description: I use "schtasks.exe" command from code if I call with ProcessLauncher this command "c:\windows\system32\schtasks.exe", "/query" working perfect.
But If would like to call "c:\windows\system32\schtasks.exe", "/run /TN \"UWFEnable\"", I receive this output: ERROR: Access is denied.

In my opinion UWP app run as Defaultaccount, that's why I have to add schedule task run permission. I tried to add DefaultAccount to Administrators group, but i received this error message: "Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))\n at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)\r\n at Windows.System.ProcessLauncher.RunToCompletionAsync(String fileName, String args, ProcessLauncherOptions options)\r\n at System.Cmd.Command.RunProcess(String Command, String Arguments)\n"

How can i run a schedule task from UWP app? And what permissions necessary to DefaultAccount? What kind of powershell command necessary?



windows-iot-10core
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SeeyaXi-msft avatar image
0 Votes"
SeeyaXi-msft answered SeeyaXi-msft edited

Hi @IntelliSense-8139,

First of all, this is an article about the various commands of Task Scheduler and here is the Microsoft doc.
Please see this link which is a similar thread: where you can see if any steps are missing.
In addition, please try to provide Everyone group Full permission in the Task path.
Have you tried using schtasks /Change /TN "<task name>" /Enable?
Please see: https://www.tenforums.com/tutorials/173777-how-enable-disable-scheduled-task-windows-10-a.html
Here is an another method about how to create a schedule task https://social.msdn.microsoft.com/Forums/windowsapps/en-US/3bef5fd8-6a9c-4626-89c7-1d7b92e4cd36/is-uwp-app-able-to-create-a-schedule-task-in-windows-scheduler?forum=wpdevelop


Best regards,
Seeya


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.