Setup WP CLI (WordPress Command Line Interface) on Windows Operating System

Post Reads 2,127 reads

Step 1 Step 1

Create folder wp-cli in C drive.

Step 2 Step 2

Download wp-cli.phar from

Step 3 Step 3

Move downloaded wp-cli.phar file in C:\wp-cli\

Step 4 Step 4

Create wp.bat file in C:\wp-cli\ and write below code in it.

php "C:\wp-cli\wp-cli.phar" %*


Download file from below Gist

Step 5 Step 5

Open system environment and set C:\wp-cli as an environment path.

Setup Environment Path
Setup Environment Path


Open Command Prompt and type command wp and press Enter. It’ll show you the like the below screenshot.

Not work on Git Bash? Not work on Git Bash?

Create another file wp without any extension into the C:\wp-cli\ directory and paste below code:

#!/usr/bin/env sh

dir=$(d=${0%[/\\]*}; cd "$d"; pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
   # Cygwin paths start with /cygdrive/ which will break windows PHP,
   # so we need to translate the dir path to windows format. However
   # we could be using cygwin PHP which does not require this, so we
   # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
   if [[ $(which php) == /cygdrive/* ]]; then
       dir=$(cygpath -m $dir);

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/wp-cli.phar" "$@"


Now open git bash and type command wp Eg.


Thanks for the suggestions Uttam Sharma!

9 thoughts on “Setup WP CLI (WordPress Command Line Interface) on Windows Operating System”

  1. Pingback: Auto translate WordPress theme and plugin strings with WP CLI – Mahesh Waghmare

  2. Pingback: Create a first WP CLI Hello World Program in WordPress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
%d bloggers like this: