Automating Task Launch and Application Check with Batch Script Auto-Run on Windows
In this post, we’ll not only walk through an updated batch script that automates launching websites, checking if Skype is running, and opening apps like Sticky Notes and Visual Studio, but also show how to set it up for automatic execution when your computer starts.
Here’s the batch script:
start chrome "https://www.youtube.com/"
start chrome "https://maheshyadav.com.np/"
@echo off
setlocal
set "appName=skype.exe"
tasklist /FI "IMAGENAME eq %appName%" | find /I "%appName%" >nul
if %ERRORLEVEL%==1 (
start %appName%
)
start shell:appsFolder\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe!App
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe"
exit
Step-by-Step Breakdown
- Opening Multiple Chrome Tabs:
start chrome "https://www.youtube.com/" start chrome "https://maheshyadav.com.np/"
This command opens YouTube and a personal website in Chrome, making it easy to access frequently visited pages automatically.
- Checking if Skype is Running:
@echo off setlocal set "appName=skype.exe" tasklist /FI "IMAGENAME eq %appName%" | find /I "%appName%" >nul
The script uses
tasklist
andfind
commands to check if Skype is running and launches it if necessary. - Launching Skype if Not Running:
if %ERRORLEVEL%==1 ( start %appName% )
if %ERRORLEVEL%==1
: This checks whether the previous command returned an exit code of1
, typically signaling an error or specific condition.start %appName%
: If the error level is1
, the script uses thestart
command to launch Skype, as%appName%
is set to Skype.
- Launching Sticky Notes and Visual Studio:
start shell:appsFolder\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe!App "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe"
These commands open Sticky Notes and Visual Studio directly, saving time by opening essential apps upon startup.
Setting Up Auto-Run for the Batch Script in Windows
To make this script run automatically when your computer starts, you can add it to Windows’ startup folder:
- Save the Batch Script:
- Save the batch script as
myAutomationScript.bat
(or any name you prefer).
- Save the batch script as
- Add to Startup Folder:
- Press
Win + R
, typeshell:startup
, and press Enter. This will open the Startup folder. - Copy your
myAutomationScript.bat
file into this folder.
Once placed in this folder, the batch script will run automatically every time you log in or start your computer.
- Press
Conclusion
This batch script not only automates daily tasks like opening websites and launching apps but can also be configured to run automatically at startup, improving your workflow from the moment your system boots up. Automating routine tasks with batch scripts is a simple yet effective way to enhance productivity.
Leave a comment