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
C:\Windows\System32\Tasks\
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(fl.name, ".") = 0 then 'Â Â Â Â Â Â Â Â objFSO.MoveFile fl, fl & ".xml" 'end if ' schtasks help ' http://ss64.com/nt/schtasks.html ' test 'oShell.Run "cmd.exe /K schtasks /create /xml """ & fl.path & """ /tn """ & TaskFolderPath & "\" & Replace( fl.name, ".xml", "" ) & """" 'WScript.echo "cmd.exe /K schtasks /create /xml """ & fl.path & """ /tn """ & TaskFolderPath & "\" & Replace( fl.name, ".xml", "" ) & """" ' cmd.exe switches: ' http://ss64.com/nt/cmd.html ' prod oShell.Run "cmd.exe /C schtasks /create /xml """ & fl.path & """ /tn """ & TaskFolderPath & "\" & Replace( fl.name, ".xml", "" ) & """" next ' fl End Sub