Automates service stop and restart cycles using scheduled tasks on Windows endpoints
This Automox Worklet™ creates two Windows scheduled tasks that run on a daily schedule to stop and restart a specified service. The Worklet uses PowerShell to register both tasks with the Windows Task Scheduler, configuring them to run as System with highest privileges.
The stop task executes the command NET STOP {serviceName} at your configured stop time. After the configured interval, the start task executes NET START {serviceName} to bring the service back online. The Worklet automatically removes any existing tasks with the same names before creating new ones, preventing duplicate entries.
Both tasks are configured with a one-hour execution timeout and set to run on battery power, verifying they execute even during power-constrained scenarios.
Windows services can accumulate memory leaks, connection pools, and resource handles over extended uptime. Scheduled restarts clear these accumulated resources, improving endpoint performance and stability without requiring manual intervention from your IT team.
This is particularly valuable for services like AMAGENT, web application hosting services, or any background process that benefits from periodic resets. Automating the restart cycle reduces downtime by running restarts during scheduled maintenance windows, and it eliminates the need for helpdesk tickets or manual RDP sessions to restart misbehaving services.
For services that cache credentials or maintain connection pools, scheduled restarts force re-authentication and reconnection, which can resolve permission-related issues and stale connection problems that manual restart requests might miss.
Evaluation phase: The Worklet checks whether scheduled tasks with the specified names already exist. If they do, it records their presence for cleanup during remediation.
Remediation phase: The Worklet unregisters any existing tasks to avoid duplicates, creates the stop task with the NET STOP command at your specified stop time, and creates the start task with the NET START command at your specified start time. Both tasks run with System privileges and are configured to execute even on battery power.
Windows 8.1, Windows 10, or Windows 11 (Server 2012 R2 and later also supported)
PowerShell 3.0 or later
Administrative privileges on the target endpoint (required for task registration)
A valid Windows service name (e.g., AMAGENT, W3SVC, SQLSERVERAGENT)
Stop and start times in 24-hour military format (HH:MM), with start time after stop time by at least one minute
After the Worklet runs, you will see two new scheduled tasks in Windows Task Scheduler under the root of the task library. You can verify this change by checking the specific setting this Worklet modifies. The first task will execute daily at your configured stop time, running NET STOP against your specified service. The second task will execute at your configured start time, running NET START to bring the service back online.
Service logs will show the service stopping and starting at the specified times each day. If the service is already running after stop time, the NET STOP command will terminate it. If the service fails to start after the start time, the task will still execute, though the service may fail to start if prerequisites are missing or the service has startup issues. Monitor the Windows Event Viewer Application log for any NET command failures or service startup errors.
Run this Worklet on a pilot Windows endpoint and review evaluation output for scheduled tasks to stop and restart a service.
Confirm Automox activity logs show successful completion and exit code 0.
Verify endpoint state using checks aligned to evaluation script logic, such as the evaluation and remediation scripts.
Validate remediation effects from script operations such as New-ScheduledTaskPrincipal, New-ScheduledTaskSettingsSet, New-TimeSpan, then rerun evaluation for compliance.


By submitting this form you agree to our Master Services Agreement and Privacy Policy.
Already have an account? Log in
Consider Worklets your easy button
A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

AUTOMOX + WORKLETS™
Uncover new possibilities with simple, powerful automation.
By submitting this form you agree to our Master Services Agreement and Privacy Policy