By Awesome As


2016-10-18 11:34:46 8 Comments

I have a batch file which will copy certain folders from an absolute path over as a backup. I currently need to make it so every midnight the batch file will be executed - and that's during the time when no one is on the computer.

Currently I've set up the task in Windows Task Scheduler to Run whether the user is logged in or not, saving the administrator's password, set a trigger each day at midnight, and start the bat file in its specified location with the path to the folder (without quotation marks) as the working directory.

<?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>

Here's the complete setup exported as XML - problem is that I can't simply assume that someone will be online to have the scheduled task run, as it's meant to run automatically when no one is using the system.

My problem is that while the task may be able to run when I manually run it (press the green run icon in the Task Scheduler), the task won't execute at the planned time, possibly due to the \tsclient\T drive not being available at the given time.

Is there any way I can access this drive when there aren't a dedicated user online on the computer?

Network location of backup batch file

The task is configured for Windows Server 2012 R2.

0 comments

Related Questions

Sponsored Content

9 Answered Questions

4 Answered Questions

13 Answered Questions

[SOLVED] Windows batch files: .bat vs .cmd?

5 Answered Questions

[SOLVED] Split long commands in multiple lines through Windows batch file

  • 2008-09-16 03:04:34
  • Dan
  • 421797 View
  • 744 Score
  • 5 Answer
  • Tags:   batch-file

9 Answered Questions

[SOLVED] What does %~d0 mean in a Windows batch file?

  • 2008-09-21 20:41:19
  • Chris Smith
  • 330552 View
  • 359 Score
  • 9 Answer
  • Tags:   windows batch-file

2 Answered Questions

[SOLVED] .BAT file not running in task scheduler

5 Answered Questions

[SOLVED] Windows Batch File - Move File not working in Task Scheduler only

Sponsored Content