任务计划程序中的 xcopy 以错误 4 结束

任务计划程序中的 xcopy 以错误 4 结束

我在任务计划程序中创建了一个任务,用于在每个午夜将特定文件复制到服务器。当我在命令行中正常运行该命令时,它工作正常,但任务总是以退出代码 4 结束,并且文件不会被复制。我在命令行中输入的命令如下:

xcopy \\<server>.<domain>.com\c$\Users\a.Name.Surname\Documents\New_ADuser_mustang.ps1 C:\IAM\New_ADuser_mustang.ps1* /C /Y /Q

在任务中,我把动作定义到动作:启动程序,程序/脚本:xcopy,以及添加参数(可选):\\<server>.<domain>.com\c$\Users\a.Name.Surname\Documents\New_ADuser_mustang.ps1 C:\IAM\New_ADuser_mustang.ps1* /C /Y /Q

任务的xml代码在这里:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2020-02-26T09:55:29.6760961</Date>
    <Author><domain>\<user></Author>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2020-02-27T00:00:00</StartBoundary>
      <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</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>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>xcopy</Command>
      <Arguments>\\<server>.<domain>.com\c$\Users\<user>\Documents\New_ADuser_mustang.ps1 C:\IAM\New_ADuser_mustang.ps1* /C /Y /Q</Arguments>
    </Exec>
  </Actions>
</Task>

相关内容