Decide what the script needs
A task that maps a drive, starts an app or copies files has different requirements from one that edits services. Admin rights and the user context decide which account the task runs as.
The startup folder is convenient and unreliable: it runs after the desktop appears, with the wrong working directory. A scheduled task is the better tool.
Create a task with the trigger **At log on**, set the action to your script with the full path, and tick **Run with highest privileges** if it needs admin. A .ps1 file needs **powershell.exe** as the program and **-File** as the argument.
A task that maps a drive, starts an app or copies files has different requirements from one that edits services. Admin rights and the user context decide which account the task runs as.
The create dialog offers the full set of triggers and conditions. The basic wizard hides the settings that make the task reliable.
taskschd.msc > Create Task
At log on plus a two-minute delay avoids competing with the shell and the network stack during sign-in. A task that needs the network fails silently without one.
For a PowerShell script the program is powershell.exe and the arguments carry the file path and the execution policy. Pointing the task at the .ps1 directly opens an editor window instead.
-NoProfile -ExecutionPolicy Bypass -File C:\cripts\ogon.ps1
Run only when the user is logged on shows a window; run whether logged on or not runs hidden and needs the stored password. A task that must interact with the desktop needs the first option.
The task history records the last result code and the exit code of the script. A zero means success; anything else tells you the script or the path failed.
Working directory or user context. Log the script output to a file to see what it did.
The trigger is wrong or the task is disabled. Check the next run time in the list.
The network is not ready yet. Add the delay or wait for a network condition.
Pass -ExecutionPolicy Bypass in the arguments rather than changing the machine policy.
For a quick user-level action with no privileges it is simpler.
Yes with a boot trigger and a service account, and it cannot show a window.
Delete the task from the task library. Nothing else changes, and the script file stays where it is.
Free · no account needed · tracks your progress