Recently, one of our workstations used for automated reports refresh “died”. OS stopped to load after reboot.

Fortunately, all necessary stuff were copied to backup.

We used “Self-Service BI for poor” approach on that machine. Excel + Vbscripts, scheduled in Windows Task Scheduler.

It’s typical task was to handle following simplified schema

  • Run Excel
  • Open workbook
  • RefreshAll (Power Query connections + Data Model)
  • Save workbook
  • Kill Excel

Repeat for all reports scheduled in Task Manager.

Similar schema is used by Power Update. And same story can happen with PU tasks as well.

So, for us it was enough to re-install Windows + MS Office. And then restore Tasks.

That machine was a working horse. At any time, at any weather, it executed tasks, quite many of tasks.

Too many to recreate manually in short time, and keep same structure of tasks folders.

I searched for ready solution on the Internet, but unfortunately found only ideas and basic things.

If you are using same approach – keep your tasks in safe place. Set up task that will copy your tasks 🙂

You may find them in


Copy all necessary folders with tasks to somewhere else.

In case of trouble use following script to restore your tasks:

TasksFolder = "T:\BackupTasks\ByD\"
RestoreTasksToFolder = "ByD"

Set oShell = WScript.CreateObject ("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Fldr = objFSO.GetFolder(TasksFolder)

ProcessBackupTasksFolder Fldr, RestoreTasksToFolder

Sub ProcessBackupTasksFolder(OfFolder, TaskFolderPath)
	For Each SubFolder In OfFolder.SubFolders
		' recursive call
		ProcessBackupTasksFolder SubFolder, TaskFolderPath & "\" & SubFolder.Name
	 Next ' SubFolder
	for each fl in ofFolder.Files
 		' backup files do not contain extension
 		' rename - for testing
 		'if Instr(, ".") = 0 then
 		'        objFSO.MoveFile fl, fl & ".xml"
 		'end if
		' schtasks help
 		' test
 		'oShell.Run "cmd.exe /K schtasks /create /xml """ & fl.path & """ /tn """ & TaskFolderPath & "\" & Replace(, ".xml", "" ) & """"
 		'WScript.echo "cmd.exe /K schtasks /create /xml """ & fl.path & """ /tn """ & TaskFolderPath & "\" & Replace(, ".xml", "" ) & """"
 		' cmd.exe switches:
		' prod
 		oShell.Run "cmd.exe /C schtasks /create /xml """ & fl.path & """ /tn """ & TaskFolderPath & "\" & Replace(, ".xml", "" ) & """"
 	next ' fl
 End Sub

Leave a Reply