0

I have created a batch file to copy files from file share to system local driver. The batch file runs fine when I trigger it manually, but it fails to run when I trigger through the task scheduler. Can anyone help me resolve this issue?

I have made it to run with highest privileges. However, it still does not work.

my batch file:

FOR /F %%a IN ("\\serverabc.com\CID\MAC\dump\test*.*") DO (move /Y %%a "E:\UserAcc\Users")

Here, I am moving all files starting with name 'test' to a the current system where I am running this batch file. I am unable to capture any logs though. If there is a way to enable logs, please let me know.

Here is my task scheduler xml file:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2019-05-07T05:29:04.2375904</Date>
    <Author>mycomp\myuser</Author>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2019-05-07T09:00:47</StartBoundary>
      <ExecutionTimeLimit>P1D</ExecutionTimeLimit>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>mycomp\myuser</UserId>
      <LogonType>S4U</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>E:\Empty\Nisha\move_file.bat</Command>
    </Exec>
  </Actions>
</Task>
nisha rao
  • 1
  • 1
  • 2
  • What is in your eventlog? – user2956477 Apr 21 '20 at 10:52
  • Task Scheduler successfully finished "{7d2fcbb9-6fdhe-45t2-a484-7a4f55439104}" instance of the "\move_file" task for user "myuser". Though it shows successful in event, I don't see the files moved to my destination. – nisha rao Apr 21 '20 at 11:41
  • 1
    You have not provided us with the task scheduler information. Which user is the task being run as? When the task is being scheduled to run? Is the network location `\\serverabc.com` available? Also are there any `test*.*` files inside an existing directory named `\\serverabc.com\CID\MAC\dump`? does the end user have permissions to move those files? and do they have the required permissions to write to `E:\UserAcc\Users`? – Compo Apr 21 '20 at 13:35
  • From the cmd prompt: `SCHTASKS /Query /?`. Then export your tasks XML file, [edit] your post and include the task XML in your post. – jwdonahue Apr 21 '20 at 15:30
  • I have added task scheduler xml file. In addition, I am running the task as my user. Although the batch file runs fine with my user when I double click, it fails to run from task scheduler. So I don't think it is a permission issue with the user. Please correct me if I'm wrong. – nisha rao Apr 22 '20 at 03:33

0 Answers0