-->

从Windows任务计划程序运行的批处理文件,无论用户登录(Run batch file from

2019-09-29 07:03发布

我有一个批处理文件,它会从一个绝对路径,通过复制特定的文件夹作为备份。 我现在需要使它所以每到半夜,批处理文件将被执行 - 而在当时那个时候没有人是在计算机上。

目前,我已经建立了在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不开车是可用在给定的时间。

有没有什么办法的时候有没有一个专门的用户上网的电脑上,我可以访问该驱动器?

备份批处理文件的网络位置

该任务配置的Windows Server 2012 R2。

文章来源: Run batch file from Windows Task Scheduler regardless of user logged in