Whilst it doesn't provide exactly the same output as your desired example, the following, seems usable, (and better), to me:
schtasks /query /fo list | findstr /r "^Folder: ^TaskName: ^Status: ^$"
Which should provide output like this:
Folder: MicrosoftWindowsWwanSvc
TaskName: MicrosoftWindowsWwanSvcNotificationTask
Status: Ready
Folder: MicrosoftXblGameSave
TaskName: MicrosoftXblGameSaveXblGameSaveTask
Status: Ready
BTW, I'm unsure what version of Windows you're intending this for, but certainly from Windows Vista, through to Windows 10, this is the output format I'm used to seeing from schtasks
:
Folder: MicrosoftWindowsWwanSvc
TaskName Next Run Time Status
======================================== ====================== ===============
NotificationTask N/A Ready
Folder: MicrosoftXblGameSave
TaskName Next Run Time Status
======================================== ====================== ===============
XblGameSaveTask N/A Ready
Which means that your output, from your provided code, would look like this:
Folder:
TaskName
========================================
NotificationTask
Folder:
TaskName
========================================
XblGameSaveTask
That also means to get the output you desire, you'd need to omit the table header borders, as well as the second table column.
Given that, here's a rather OTT method of potentially achieving that from a batch-file:
@Echo Off & SetLocal EnableExtensions DisableDelayedExpansion
Set "{= "
For /F "Delims=" %%G In ('%SystemRoot%System32schtasks.exe /Query ^
^| %SystemRoot%System32findstr.exe /R "^[^=]"') Do (Set "}=%%G"
SetLocal EnableDelayedExpansion & Set "}=!}: =|!"
For /F "Tokens=1,3 Delims=|" %%H In ("!}:| =||!") Do If "%%I" == "" (
Echo %%H) Else Set "z=%%H%{%" & Echo=!z:~,41!%%I
EndLocal)
Pause
This should output this for you:
Folder: MicrosoftWindowsWwanSvc
TaskName Status
NotificationTask Ready
Folder: MicrosoftXblGameSave
TaskName Status
XblGameSaveTask Ready