1 minute read

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

  1. 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.

  2. 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 and find commands to check if Skype is running and launches it if necessary.

  3. Launching Skype if Not Running:
    if %ERRORLEVEL%==1 (
        start %appName%
    )
    
    • if %ERRORLEVEL%==1: This checks whether the previous command returned an exit code of 1, typically signaling an error or specific condition.
    • start %appName%: If the error level is 1, the script uses the start command to launch Skype, as %appName% is set to Skype.
  4. 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:

  1. Save the Batch Script:
    • Save the batch script as myAutomationScript.bat (or any name you prefer).
  2. Add to Startup Folder:
    • Press Win + R, type shell: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.

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