Task Scheduler – Random IT Utensils https://blog.adamfurmanek.pl IT, operating systems, maths, and more. Sat, 02 Jan 2021 19:05:55 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 Availability Anywhere Part 6 — Task scheduler not running on next run date on Windows Home edition https://blog.adamfurmanek.pl/2020/06/20/availability-anywhere-part-6/ https://blog.adamfurmanek.pl/2020/06/20/availability-anywhere-part-6/#comments Sat, 20 Jun 2020 08:00:23 +0000 https://blog.adamfurmanek.pl/?p=3350 Continue reading Availability Anywhere Part 6 — Task scheduler not running on next run date on Windows Home edition]]>

This is the sixth part of the Availability Anywhere series. For your convenience you can find other parts in the table of contents in Part 1 – Connecting to SSH tunnel automatically in Windows

There is some bug with Task Scheduler not running the task on the next run date, similar to this question. In my case it was happening on Windows 10 Home edition on two different machines. I checked multiple solutions and none of them worked for me, the task was configured correctly but it wasn’t triggered.

I finally gave up and changed the script. Because I wanted to trigger a bat file every minute, I just changed the script. Previously I had a script VPN.bat which was triggered every minute to reconnect the VPN and configure the DNS. Now, I changed it to this:

:begin
start FULL_SCRIPT_PATH

timeout /t 30
goto begin

So I just run this script which works indefinitely and starts the other script. Now, it is important that the other script has explicit exit in it to avoid leaking cmd.exe instances.

Then I changed Task Scheduler to run the script on system startup. I also chose rerunning it every minute and not running in parallel, but it doesn’t matter as Task Scheduler doesn’t trigger it correctly.

]]>
https://blog.adamfurmanek.pl/2020/06/20/availability-anywhere-part-6/feed/ 1
UpdateOrchestrator waking up the machine https://blog.adamfurmanek.pl/2020/03/07/updateorchestrator-waking-up-the-machine/ https://blog.adamfurmanek.pl/2020/03/07/updateorchestrator-waking-up-the-machine/#comments Sat, 07 Mar 2020 09:00:08 +0000 https://blog.adamfurmanek.pl/?p=3255 Continue reading UpdateOrchestrator waking up the machine]]> Recently I was investigating machine waking up from sleep without any user interaction. It was a bit irritating because user was putting his PC to sleep and leaving it for a day just to notice in the evening that the machine woke up and was on for most of the time.

Event viewer showed this:

The system has returned from a low power state.

Sleep Time: ?2019?-?11?-?04T15:51:17.837661000Z
Wake Time: ?2019?-?11?-?04T16:09:31.442527100Z

Wake Source: Timer - Windows will execute 'NT TASK\Microsoft\Windows\UpdateOrchestrator\Universal Orchestrator Start' scheduled task that requested waking the computer.

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Microsoft-Windows-Power-Troubleshooter" Guid="{cdc05e28-c449-49c6-b9d2-88cf761644df}" /> 
  <EventID>1</EventID> 
  <Version>3</Version> 
  <Level>4</Level> 
  <Task>0</Task> 
  <Opcode>0</Opcode> 
  <Keywords>0x8000000000000000</Keywords> 
  <TimeCreated SystemTime="2019-11-04T16:09:31.658173400Z" /> 
  <EventRecordID>14127</EventRecordID> 
  <Correlation ActivityID="{0bdacabc-df50-4751-a5a5-8d03debed195}" /> 
  <Execution ProcessID="4416" ThreadID="17628" /> 
  <Channel>System</Channel> 
  <Computer>SEA-1800030347.ant.amazon.com</Computer> 
  <Security UserID="S-1-5-19" /> 
  </System>
- <EventData>
  <Data Name="SleepTime">2019-11-04T15:51:17.837661000Z</Data> 
  <Data Name="WakeTime">2019-11-04T16:09:31.442527100Z</Data> 
  <Data Name="SleepDuration">7800</Data> 
  <Data Name="WakeDuration">2942</Data> 
  <Data Name="DriverInitDuration">1650</Data> 
  <Data Name="BiosInitDuration">628</Data> 
  <Data Name="HiberWriteDuration">0</Data> 
  <Data Name="HiberReadDuration">0</Data> 
  <Data Name="HiberPagesWritten">0</Data> 
  <Data Name="Attributes">1879073024</Data> 
  <Data Name="TargetState">4</Data> 
  <Data Name="EffectiveState">4</Data> 
  <Data Name="WakeSourceType">6</Data> 
  <Data Name="WakeSourceTextLength">147</Data> 
  <Data Name="WakeSourceText">Windows will execute 'NT TASK\Microsoft\Windows\UpdateOrchestrator\Universal Orchestrator Start' scheduled task that requested waking the computer.</Data> 
  <Data Name="WakeTimerOwnerLength">52</Data> 
  <Data Name="WakeTimerContextLength">18</Data> 
  <Data Name="NoMultiStageResumeReason">0</Data> 
  <Data Name="WakeTimerOwner">\Device\HarddiskVolume4\Windows\System32\svchost.exe</Data> 
  <Data Name="WakeTimerContext">SystemEventsBroker</Data> 
  <Data Name="CheckpointDuration">108</Data> 
  </EventData>
  </Event>

So it looks like there was some update task waking the computer. After opening the Task Scheduler we could see this:

There are two important things you can see (even though screenshot is in Polish). First, owner of the task is NT SYSTEM. Second, it is scheduled to run at 8:58 AM.

So we know why the machine was waking up. How can we disable the task? Starting Task Scheduler as an administrator didn’t allow us to disable the task.

The thing is: Administrator is not the most powerful account in Windows. SYSTEM account has more privileges and we need to use it to disable the task. How do we run Task Scheduler as NT SYSTEM?

I typically use psexec from Sysinternals. Just run this command:

psexec -s -i mmc.exe

This opens management console. Add snap-in for Task Scheduler and you are good to go. Now you can disable the task and see that it solves the issue.

]]>
https://blog.adamfurmanek.pl/2020/03/07/updateorchestrator-waking-up-the-machine/feed/ 1