Welcome to Microsoft Q&A Forum!
When a scheduled task on Windows Server 2019 starts successfully but terminates after only a few seconds without completing, this behavior is usually caused by task configuration, execution context or script behavior, not by a failure of Task Scheduler itself. The common causes include:
- Missing or incorrect “Start in” (working directory)
Scripts that rely on relative paths (VBS, SAS jobs, batch files) may exit immediately when run by Task Scheduler because the default working directory is C:\Windows\System32 if not explicitly set.
- Non‑interactive execution context Scheduled tasks run in a background session. Scripts that depend on:
- User profiles
- Mapped drives (not UNC paths)
- UI prompts or dialogs may exit early when running unattended.
- Execution limits configured in the task
The setting “Stop the task if it runs longer than…” can prematurely terminate jobs, especially legitimate long‑running report or ETL tasks.
- Script exits without throwing an error If a script encounters a missing dependency or logic path that triggers an early exit, Task Scheduler will not report a failure unless script‑level logging is implemented
I would like to share the following recommended solutions that may help you.
1. Validate the task configuration
Microsoft recommends verifying:
- Program/Script
- Arguments
- Start in (explicitly set the correct working directory)
- Run whether user is logged on or not
- Disable execution time limits temporarily for testing.
2. Test the script outside Task Scheduler
Run the script manually using its intended host (for example, cscript.exe for VBS). If it exits early outside Task Scheduler, the issue is script‑side, not scheduler‑side.
3. Monitor server resource utilization
High CPU, memory pressure, or disk I/O contention during peak periods can cause:
- Script timeouts
- Dependent processes failing to initialize Microsoft recommends monitoring resource usage during task execution.
4. Add script‑level logging
Microsoft explicitly advises not relying solely on Task Scheduler status:
- Log entry/exit points inside the script
- Capture exit codes
- Log errors before termination This is often the only way to determine why a task exits early in unattended mode.
Note: If a scheduled task starts and then stops after a few seconds, Task Scheduler is working as designed. Microsoft documentation shows the root cause is almost always script execution context, working directory, or task execution limits, not Task Scheduler itself. Correcting the task configuration and ensuring the script is designed for unattended execution resolves this issue in most cases.
Reference: Scheduled Tasks Not Running - Windows Server | Microsoft Learn
I hope this information is helpful and thank you for choosing Microsoft Q&A to raise your concern.