schtasks

package
v1.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const TaskName = taskName

TaskName is the Windows scheduled task name. Exported so other packages (e.g. schedinfo) can query the task without re-deriving the constant.

View Source
const UpdateTaskName = updateTaskName

UpdateTaskName is exported for diagnostics (schedinfo-style queries).

Variables

This section is empty.

Functions

func Install

func Install(exec executor.Executor, log *progress.Logger, maxExec time.Duration) error

Install configures Windows Task Scheduler for periodic scanning. If already installed, upgrades by removing and re-creating the task. maxExec is the agent's execution-watchdog duration (0 = disabled); the task's ExecutionTimeLimit is derived from it.

func IsTaskRegistered added in v1.11.4

func IsTaskRegistered(ctx context.Context, exec executor.Executor) bool

IsTaskRegistered reports whether the Windows scheduled task created by `dev-machine-guard install` is currently registered. Used by the telemetry package's invocation detector to distinguish a manual CLI run from a scheduler-triggered one. Any error or non-zero schtasks exit is treated as "not registered" so a transient Schedule-service hiccup degrades to "one_time" rather than erroring the run.

func ReconcileTaskSettings added in v1.19.0

func ReconcileTaskSettings(exec executor.Executor, log *progress.Logger, maxExec time.Duration) (perSession, registered bool)

ReconcileTaskSettings re-applies the scan tasks' settings to whatever is registered now: power and retry settings, the execution limit and, on a host that scans per session, MultipleInstancesPolicy=Parallel. The policy is decided at install time from what the host is then, but a host turns shared later (the sticky marker, a second established developer) and a self-update swaps binaries without touching the tasks, so such a host would keep IgnoreNew and drop a second session's scan while the first still runs. The SYSTEM updater calls this on every tick. Reports whether the host scans per session and whether the tasks were registered at all (a loader install or no install is a no-op).

func RunNow added in v1.11.7

func RunNow(exec executor.Executor, log *progress.Logger) error

RunNow asks Task Scheduler to fire the registered task immediately, using its configured principal (/ru INTERACTIVE for admin installs). Used by the install flow under LocalSystem to surface first-run telemetry under the logged-in user rather than scanning SYSTEM's empty profile inline.

schtasks /run returns 0 once the scheduler has accepted the request; it does not wait for the task to complete and does not report whether an interactive session exists. If no user is logged in, the trigger silently no-ops and the task fires on its next hourly tick.

func Uninstall

func Uninstall(exec executor.Executor, log *progress.Logger) error

Uninstall removes the scheduled task. For an MSI bootstrap install it also removes the update task, stops running DMG processes and deletes the self-update state (see uninstallBootstrap).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL