Windows 10 - Tarefa Agendada - Desligamento

0

Estou tentando fazer com que minha VM Win10 seja desligada todos os dias à meia-noite. Eu testei via powershell que o comando

shutdown /f /s /t 1

funciona perfeitamente.

Eu também criei uma tarefa e vejo que ela é disparada, mas a máquina não é desligada. O mesmo acontece se eu tentar executar a tarefa sozinho:

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}" /> 
  <EventID>200</EventID> 
  <Version>1</Version> 
  <Level>4</Level> 
  <Task>200</Task> 
  <Opcode>1</Opcode> 
  <Keywords>0x8000000000000000</Keywords> 
  <TimeCreated SystemTime="2018-01-10T08:02:13.412265700Z" /> 
  <EventRecordID>480</EventRecordID> 
  <Correlation ActivityID="{4C02EED4-A58E-4DC8-B626-1CDA89362E4D}" /> 
  <Execution ProcessID="960" ThreadID="3396" /> 
  <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel> 
  <Computer>PC</Computer> 
  <Security UserID="S-1-5-18" /> 
  </System>
- <EventData Name="ActionStart">
  <Data Name="TaskName">\Custom\Shutdown</Data> 
  <Data Name="ActionName">C:\Windows\System32\shutdown.exe</Data> 
  <Data Name="TaskInstanceId">{4C02EED4-A58E-4DC8-B626-1CDA89362E4D}</Data> 
  <Data Name="EnginePID">4624</Data> 
  </EventData>
  </Event>

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}" /> 
  <EventID>201</EventID> 
  <Version>2</Version> 
  <Level>4</Level> 
  <Task>201</Task> 
  <Opcode>2</Opcode> 
  <Keywords>0x8000000000000000</Keywords> 
  <TimeCreated SystemTime="2018-01-10T08:02:13.720117600Z" /> 
  <EventRecordID>482</EventRecordID> 
  <Correlation ActivityID="{4C02EED4-A58E-4DC8-B626-1CDA89362E4D}" /> 
  <Execution ProcessID="960" ThreadID="3396" /> 
  <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel> 
  <Computer>PC</Computer> 
  <Security UserID="S-1-5-18" /> 
  </System>
- <EventData Name="ActionSuccess">
  <Data Name="TaskName">\Custom\Shutdown</Data> 
  <Data Name="TaskInstanceId">{4C02EED4-A58E-4DC8-B626-1CDA89362E4D}</Data> 
  <Data Name="ActionName">C:\Windows\System32\shutdown.exe</Data> 
  <Data Name="ResultCode">2147942401</Data> 
  <Data Name="EnginePID">4624</Data> 
  </EventData>
  </Event>

Alguém pode me apontar para o problema aqui? Abaixo está a tarefa como exportada:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2018-01-09T23:18:33.1522429</Date>
    <Author>PC\user</Author>
    <URI>\Custom\Shutdown</URI>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2018-01-10T00:55:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>xxxxxxx</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>false</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT10M</Duration>
      <WaitTimeout>PT1H</WaitTimeout>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>true</RunOnlyIfIdle>
    <WakeToRun>true</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT1H</Interval>
      <Count>3</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Windows\System32\shutdown.exe</Command>
      <Arguments>\f \s \t 1</Arguments>
    </Exec>
  </Actions>

Muito obrigado

    
por JoeSlav 10.01.2018 / 09:28

1 resposta

1

Parece que você usou barras invertidas no campo de argumentos ( \f \s \t 1 )

Use isso:

/f /s /t 1

    
por 10.01.2018 / 09:47