The Most Useful Windows Autorun Commands and How to Use Them
Windows provides several ways to run commands automatically. Some commands run when you log in, some run when CMD opens, and some run at system startup before you even sign in. These autorun methods are useful for system maintenance, automation, environment setup, and launching tools without manual effort.
Before we look at the commands themselves, here is how to create shortcuts, how to create batch files, and how to place them in the Startup folder. These steps are important because many autorun methods rely on these simple tools.
How to Create a Shortcut for Autorun
You can make any command run at login by creating a shortcut and placing it in the Startup folder. This works for CMD commands, PowerShell commands, and applications.
Step One Right click on the desktop and select New then Shortcut.
Step Two In the location box enter the command you want to run. For example
cmd /k winget upgrade --all --include-unknown
Step Three Name the shortcut anything you want.
Step Four Press the Windows key and R together to open the Run box. Type the following and press Enter.
shell:startup
This opens the Startup folder. Move your shortcut into this folder and Windows will run it automatically when you sign in.
How to Create a Batch File for Autorun
A batch file is a simple text file that contains one or more commands. Windows can run it automatically at login or startup.
Step One Open Notepad.
Step Two Type your commands into the file. For example
@echo off
ipconfig /flushdns
chkdsk /scan
Step Three Save the file with a .bat extension. For example
startup_tasks.bat
Step Four Press the Windows key and R together to open the Run box. Type the following and press Enter.
shell:startup
Copy your batch file into this folder and Windows will run it automatically each time you sign in.
Autorun Commands When You Log In
The Startup folder is the simplest way to run commands every time you sign in. Anything placed here launches automatically. These examples show useful commands that can run as soon as you log in.
This command opens CMD and immediately runs Winget to upgrade all available packages. It is useful if you want your system to update itself every time you sign in.
cmd /k winget upgrade --all --include-unknown
This command runs a PowerShell script automatically at login. It is useful for tasks such as cleanup routines, environment setup, or launching background processes.
powershell.exe -ExecutionPolicy Bypass -File "C:\path\script.ps1"
This command opens a folder automatically when you sign in. It is useful if you want quick access to a workspace or project directory.
explorer.exe C:\SomeFolder
This command opens Task Manager automatically. It is useful for monitoring startup performance or keeping an eye on system activity.
taskmgr.exe
This command opens a notes file automatically. It is useful if you keep daily reminders or a running task list in a text file.
notepad.exe C:\notes.txt
Autorun Commands When CMD Opens
CMD has an AutoRun feature that executes a command every time a new CMD window starts. This is useful for environment setup, aliases, and workflow improvements.
This command creates a simple alias that lists files in a clean format. It is useful for faster navigation.
doskey ll=dir /b
This command forces CMD to always start in a specific directory. It is useful if you work in the same folder frequently.
cd /d C:\Work
This command adds a tools folder to your PATH automatically. It is useful if you keep utilities in a custom directory.
set PATH=%PATH%;C:\Tools
This command clears the screen every time CMD opens. It is useful if you prefer a clean workspace.
cls
Autorun Commands at System Startup
Task Scheduler is the most powerful and reliable way to run commands at system startup. It works before login and supports elevated privileges without a UAC prompt.
This command runs a PowerShell script automatically at system startup. It is useful for administrative tasks that must run before you sign in.
powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\Startup.ps1
This command runs a batch file silently at startup. It is useful for background tasks that do not need a visible window.
cmd.exe /c C:\Scripts\startup.bat
This command starts a specific service early in the boot process. Replace ServiceName with the actual service you want to start.
sc start ServiceName
This command ensures a service is running before login. It is useful for network services or monitoring tools.
net start ServiceName
This command clears the DNS cache at startup. It is useful if you experience DNS issues or use dynamic DNS services.
ipconfig /flushdns
This command performs a non intrusive disk scan at startup. It is useful for detecting file system issues early.
chkdsk /scan
How to Use Task Scheduler for Startup Automation
Task Scheduler is the most reliable way to run commands at system startup. It works before login and supports elevated privileges without showing a UAC prompt.
Step One Open the Start menu and search for Task Scheduler.
Step Two Select Create Task on the right side.
Step Three In the General tab check Run with highest privileges.
Step Four Go to the Triggers tab and select New then choose At startup.
Step Five Go to the Actions tab and select New then choose Start a program.
Step Six In the Program box enter the command or browse to your batch file. For example
powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\Startup.ps1
Step Seven Save the task.
Your command or script will now run automatically every time Windows starts, even before you sign in.
Final Thoughts
Windows provides multiple ways to automate commands and each method has its own strengths. Whether you want to run updates automatically, prepare your CMD environment, or launch scripts at boot, choosing the right autorun method makes your workflow smoother and more efficient.
Windows autorun tutorial, Windows startup automation, create batch files, shell startup command, CMD autorun, PowerShell automation, Task Scheduler guide, system maintenance scripts, Windows shortcuts, startup folder
