无论用户是否登录,都从Windows任务计划程序运行批处理文件

时间:2016-10-18 11:34:46

标签: windows batch-file taskscheduler

我有一个批处理文件,它会将绝对路径中的某些文件夹作为备份复制。我目前需要这样做,所以每个午夜都会执行批处理文件 - 这是在计算机上没有人的时候。

目前我已在Windows任务计划程序中设置任务以运行用户是否登录,保存管理员密码,每天午夜设置触发器,并在指定位置启动bat文件文件夹的路径(不带引号)作为工作目录。

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4"     xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2016-10-12T12:47:13.4632673</Date>
    <Author>GROUP\ini</Author>
    <Description>Creates a backup of DemoTestTool daily</Description>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2016-10-18T00:00:00Z</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>DEMO-TEST-SQL\Administrator</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
    <WakeToRun>true</WakeToRun>
    <ExecutionTimeLimit>PT4H</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT2H</Interval>
      <Count>3</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>\\tsclient\T\Main\Demo- Test_Tool\Programdata\Backup\BackupSys.bat</Command>
      <WorkingDirectory>\\tsclient\T\Main\Demo-Test_Tool\Programdata\Backup</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

这是以XML格式导出的完整设置 - 问题是我不能简单地假设有人会在线运行计划任务,因为它意味着在没有人使用系统时自动运行。

我的问题是,当我手动运行任务时可以运行任务(按任务计划程序中的绿色运行图标),任务将不会在计划的时间执行,可能是由于\ tsclient \ T驱动器在给定时间不可用。

如果计算机上没有专门的在线用户,我有什么方法可以访问此驱动器吗?

Network location of backup batch file

为Windows Server 2012 R2配置了该任务。

0 个答案:

没有答案