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

IntelliSense 46 Reputation points
2021-10-28T11:19:20.24+00:00

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 for IoT
Windows for IoT
A family of Microsoft operating systems designed for use in Internet of Things (IoT) devices.
381 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,446 Reputation points
    2021-11-01T05:36:11.753+00:00

    Hi @IntelliSense ,

    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.

    0 comments No comments