3

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 Answers1

-1

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.

mikes88
  • 15
  • 3
  • 2
    Hi Mike, the build in Task Scheduler is no option in my case. The task will be deployed on nearly 8.000 workstations. So command line usage is a must-have to complete the job. I am now thinking of another idea: Writing a Windows service, which starts automatically during Windows boot instead of using a task. I will discuss this with my colleagues. – user1014617 Mar 06 '15 at 14:31