How to install WP CLI in Windows

What is WP CLI?

As part of my experience working on WordPress since 2009, which counts as more than 14 years, one of the working tools I would recommend to new WordPress developers is WP CLI.

So what is WP CLI? It’s a command line interface that allows developer to manage their WordPress sites using command prompt, if you are using Windows or Terminal if you are using Linux.

One of the commands that is useful(to me at least) is when I clean up thousands of spam comments without using bulk action, which is limited to 25 posts deletion per request. Not to mention that would be time-consuming. A single WP CLI command will do this once in under 1-3 seconds.

$ wp comment delete $(wp comment list --status=spam --format=ids)

How to install WP CLI?

While I recommend developers use Linux-based operating systems for their workstations, some of us still find Windows as our main operating system. This tutorial will walk you through installing WP CLI on Windows.

The first thing I would recommend is that we avoid using Windows default command prompt and instead use git-scm. Download and install https://git-scm.com/download/win first. We will use this command interface for the rest of our work.

Second, we need to install Composer. Download Composer-Setup.exe which will give you the latest Composer version, then we need to setup Composer in our Windows PATH. This will let you use composer command from any directory. Verify if your composer installed properly by using using the following command:

$ cd C:/
$ C:/ composer -V

Once you’re done, create a new directory in C:/, depending on what drive letter your Windows is using. It should be using C:/ as default but double-check your local install. Download https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar and save it in our new directory. Now using Visual Editor IDE or anything you are comfortable with, create a new batch file and name it wp.bat for our alias.

Save the following code on your wp.bat file:

@ECHO OFF
php "%~dp0wp-cli.phar" %*

Set the variable Path in your local environment. Go over to System Properties -> Advanced System Properties -> Advanced. Click on the Environment Variables under the System Variables and find the variable name Path. Add ;C:\WP-CLI and click save. Restart the bash interface you are using at the moment and type wp cli version.

If you can see WP-CLI 2.x.x, then it means you have successfully installed WP CLI.

Happy coding!


  • Joined WCUS 2025 Contributor Day Remotely – Hosting Team Wins

    This year I got the chance to join WordCamp US 2025 Contributor Day remotely, and I’m really happy to share that I was able to contribute to the Hosting Team. Even though I wasn’t there in person, it honestly felt like being part of the action. The collaboration, support, and energy from everyone made it…

  • Recognized in WordPress Core – August 2025

    I’m really happy to share that my name showed up in the official A Month in Core report for August 2025 on: It’s a monthly update that highlights everyone who helped push WordPress Core forward, and it feels good to be included again. Most of my work in August was about testing, reviewing, and sending…

  • Chronicle Journal: Now Live on WordPress.org

    Excited to share that my latest WordPress block theme, Chronicle Journal, officially went live on the WordPress.org Theme Directoryon August 31, 2025. Why I Built Chronicle Journal The idea behind Chronicle Journal was simple: to create a theme that feels timeless, elegant, and ready for long-form storytelling. With so many websites focusing on fast snippets…

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *