MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / processWindowsTaskScheduler

Function processWindowsTaskScheduler

cmd/discover_logic_windows.go:443–635  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

441}
442
443func processWindowsTaskScheduler() bool {
444 const CronitorWindowsPath = "C:\\Program Files\\cronitor.exe"
445
446 taskService, err := taskmaster.Connect()
447 if err != nil {
448 log(fmt.Sprintf("err: %v", err))
449 return false
450 }
451 defer taskService.Disconnect()
452 collection, err := taskService.GetRegisteredTasks()
453 if err != nil {
454 log(fmt.Sprintf("err: %v", err))
455 return false
456 }
457 defer collection.Release()
458
459 // Read crontab into map of Monitor structs
460 monitors := map[string]*lib.Monitor{}
461 monitorToRegisteredTask := map[string]taskmaster.RegisteredTask{}
462 exited := false
463 for _, task := range collection {
464 if exited {
465 break
466 }
467 t := NewWrappedWindowsTask(task)
468 // Skip all built-in tasks; users don't want to monitor those
469 if t.IsMicrosoftTask() {
470 continue
471 }
472
473 // Skip tasks that only have disabled, one-time, or session state change triggers
474 if !shouldIncludeTask(task) {
475 continue
476 }
477
478 defaultName := t.FullName()
479 tags := createTags()
480 key := t.WindowsKey()
481 name := defaultName
482 skip := false
483
484 // Check if we have an existing monitor name for this task
485 existingMonitors.CurrentKey = key
486 existingMonitors.CurrentCode = ""
487 isMonitored := false
488 if existingName, err := existingMonitors.GetNameForCurrent(); err == nil {
489 name = existingName
490 isMonitored = true
491 }
492
493 if !isAutoDiscover {
494 fmt.Println(renderJobInfoBox(name, "", t.GetCommandToRun(), isMonitored))
495 for {
496 model := initialNameInputModel(name)
497 p := tea.NewProgram(model)
498
499 if result, err := p.Run(); err == nil {
500 finalModel := result.(nameInputModel)

Callers

nothing calls this directly

Calls 15

IsMicrosoftTaskMethod · 0.95
FullNameMethod · 0.95
WindowsKeyMethod · 0.95
GetCommandToRunMethod · 0.95
logFunction · 0.85
NewWrappedWindowsTaskFunction · 0.85
shouldIncludeTaskFunction · 0.85
createTagsFunction · 0.85
renderJobInfoBoxFunction · 0.85
initialNameInputModelFunction · 0.85
printWarningTextFunction · 0.85
printErrorTextFunction · 0.85

Tested by

no test coverage detected