Scheduled task builder: schtasks and Register-ScheduledTask

Build schtasks and PowerShell scheduled task commands, with the traps that make tasks fail flagged

Build a scheduled task as a schtasks /create line and as Register-ScheduledTask PowerShell, from the same form. The builder writes the powershell.exe -File wrapper for you, quotes paths correctly, never puts a password in the command, and flags the settings that make tasks fail silently: a missing working directory, a mapped drive under SYSTEM, a command line that is too long, a date in the wrong regional format.

Build schtasks and Register-ScheduledTask commands, with the traps that make tasks fail flagged.

Runs in your browser
Task
Action
Trigger
days
On
minutes
every minutes for hours
Run as

Run the commands in an elevated window. Nothing here runs anything: the tool only builds text, and it never asks for a password.

How to use

  1. Start from a common task, or fill in the name and the Task Scheduler folder.
  2. Pick the action: a Windows PowerShell 5.1 script, a PowerShell 7 script, a batch file or a program. Give the path and Start in, the folder the script expects to run from.
  3. Pick the trigger and, for time-based triggers, an optional repetition every N minutes.
  4. Pick who it runs as. SYSTEM for machine jobs, a named account or a gMSA for jobs that need network access with a domain identity.
  5. Read the warnings, then copy the Command Prompt line or the PowerShell block. Use the check block to confirm the task and run it once by hand.

Why scheduled tasks fail, and what the builder does about it

TrapWhat happensWhat the builder does
A .ps1 file set as the programTask Scheduler does not run a script file as a program: it opens it with the default app, often Notepad, or fails.Wraps it: powershell.exe -NoProfile -ExecutionPolicy Bypass -File "...", or pwsh.exe for PowerShell 7.
No working directoryThe script runs in System32, so relative paths and .\ references break.Sets Start in in PowerShell. schtasks has no switch for it: the builder says so, and offers the PowerShell form.
Mapped drive lettersDrive letters mapped in your session do not exist for SYSTEM or for a task that runs without a logged-on user.Warns and suggests the UNC path. Under SYSTEM the share must also allow the computer account.
Password in the commandA password typed into /rp or -Password ends up in shell history and scripts.Never writes one. schtasks prompts for it; PowerShell uses Get-Credential, or a gMSA with no password at all.
Command line too longschtasks /tr refuses a run string longer than 261 characters.Counts it and switches you to the PowerShell form when it is too long.
Start date format/sd follows the regional settings of the machine; an ISO date is refused on Italian settings, for example.Warns when a start date is set. The PowerShell form is not affected.
Triggers PowerShell cannot buildNew-ScheduledTaskTrigger has no monthly, idle or event trigger.Uses schtasks for those, and adds a Set-ScheduledTask step when the task also needs Start in or a gMSA.

FAQ

Frequently asked questions

Use PowerShell when you can: it sets the working directory, handles a gMSA and a logon trigger for one user, and has no 261-character limit on the command line. Use schtasks for monthly, idle and event triggers, which the PowerShell cmdlet cannot create, and on machines where you only have a Command Prompt. The builder shows both and tells you when one of them cannot express the task.

Practical examples

Example 1: nightly backup script as SYSTEM. C:\Scripts\backup.ps1 every day at 02:00, run from C:\Scripts, in the \Admin\ folder of Task Scheduler. The schtasks line and the PowerShell block both come out; only PowerShell keeps the working directory. Open in the builder.

Example 2: cleanup every 15 minutes in working hours. A batch file on weekdays from 08:00, repeated every 15 minutes, as a service account whose password is asked for when the command runs. Open in the builder.

Example 3: react to an account lockout. Event ID 4740 in the Security log starts an alert script, run as a gMSA so no password is stored anywhere. The event trigger comes from schtasks, the gMSA from a Set-ScheduledTask step. Open in the builder.

Other tools


Related guides