Create scheduled task with administrative rights running from normal user account

1.3k Views Asked by At

I am creating an scheduled task during installation of an application. The installer itself is running with administrator permissons:

SchTasks /F /create /tn "MyApp Start" /XML "D:\MyApps\start.xml" /ru "System"

This task is intended to start during system startup, which is working fine as long as the user who is logging in is the one who created the task.

In my special case the task should also run if another non-admin-user is logging in.

Currently the task is not running, if the non-admin-user is logging in. Even more, the task ist not visible to him at all.

The question is: How can I create a scheduled task as administrator

  • using DOS or PowerShell-comnmands
  • that runs with System priviliges
  • that starts even if a normal non-admin-user logs into Windows 7/8

Here is my xml-description of the task.

<?xml version="1.0"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2015-03-02T22:54:11</Date>
    <Author>foobar</Author>
  </RegistrationInfo>
  <Triggers>
    <BootTrigger>
      <StartBoundary>2015-03-02T22:54:11</StartBoundary>
      <Enabled>true</Enabled>
    </BootTrigger>
  </Triggers>
  <Principals>
    <Principal>
      <UserId>S-1-5-18</UserId>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT10M</Duration>
      <WaitTimeout>PT1H</WaitTimeout>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions>
    <Exec>
      <Command>D:\MyApps\start.bat</Command>
    </Exec>
  </Actions>
</Task>

Do you have any suggestions?

Best Regards Tobias

1

There are 1 best solutions below

1
mikes88 On

Tobias, I actually use the built in Windows Task Scheduler to set up these types of operations. I find it alot easier than using CMD and it has all the options, features, triggers, etc that you may be looking for. I use it to draft tasks and eventually push them onto our network. Not to mention it can be accessed under normal and admin user rights by default. Hope this points you in the right direction.

Mike.