If you’ve ever tried to run a .sh file on Windows, you’ve probably noticed that it doesn’t open the same way it does on Linux or macOS. That’s because Windows doesn’t natively support Bash or shell scripting — it relies on CMD or PowerShell by default.
But don’t worry — there are several easy ways to run shell scripts on Windows 11, whether you’re a developer testing a Linux environment, automating tasks, or using open-source tools. In this guide, we’ll explain what a .sh file is, and show you different methods to execute shell scripts on Windows using tools like WSL, Git Bash, and PowerShell.
What Is a .SH File?
A .sh file (short for “shell script”) contains a series of commands that can be executed in a Unix shell — like Bash, Zsh, or Korn. These scripts are widely used in Linux environments for automation, configuration, and running repetitive tasks.
However, because Windows doesn’t include Bash by default, trying to run a .sh file without proper setup will result in an error such as “command not recognized”. That’s where alternative methods like Windows Subsystem for Linux (WSL) or Git Bash come in handy.
Method 1: Run Shell Scripts Using WSL (Recommended)
If you’re using Windows 10 or 11, the easiest and most reliable way to run .sh scripts is by using Windows Subsystem for Linux (WSL) — which lets you run a full Linux environment inside Windows.
- Enable WSL
- Open PowerShell as Administrator.
- Run this command:
wsl --install - Restart your PC after installation.
- Install a Linux Distribution
- Once WSL is installed, open Microsoft Store and install a distribution like Ubuntu or Debian.
- Run the Script
- Open your Linux terminal (Ubuntu).
- Navigate to the folder containing your
.shfile using:cd /mnt/c/Users/YourUsername/Downloads - Make the script executable:
chmod +x script.sh - Then run it:
./script.sh
Tip: If you plan to work with Linux tools regularly, WSL2 is the best long-term solution — it offers full system call compatibility and better performance.
Method 2: Run Shell Scripts Using Git Bash
If you don’t want to install WSL, another great option is Git Bash — a lightweight terminal that brings Unix commands to Windows.
- Download Git Bash
- Go to git-scm.com and download Git for Windows.
- Install Git Bash
- Run the installer and keep default settings (make sure “Git Bash Here” is checked).
- Run Your Script
- Right-click the folder containing your
.shfile → click “Git Bash Here.” - Then type:
./script.sh - Press Enter to execute the script.
- Right-click the folder containing your
Tip: Git Bash supports most Linux commands, making it ideal for lightweight scripting without full WSL setup.
Method 3: Run Shell Scripts Using PowerShell (Alternative)
If you prefer sticking to native Windows tools, you can technically run .sh scripts through PowerShell — though you’ll need to invoke a Linux-like environment first.
- Open PowerShell and navigate to the script directory:
cd "C:\path\to\your\script" - Use the bash command (if installed via WSL or Git):
bash script.sh
This works best if WSL or Git Bash is already configured, since PowerShell itself doesn’t interpret .sh syntax directly.
Wrapping Up
Running .sh scripts on Windows 11 is easier than ever — thanks to WSL and Git Bash. Whether you’re coding, testing automation scripts, or experimenting with Linux tools, these methods give you flexibility and control right inside your Windows setup.
If you’re just starting out, try Git Bash for simplicity. But if you want full Linux integration, go with WSL2 — it’s the most seamless and developer-friendly option for running shell scripts on Windows.