WP Cli will not execute on Windows

I have tried to install Wordpress CLI on my windows machine running windows 10. But for some reason everytime i try to run the

wp

Command it says

'sh' is not recognized as an internal or external command,operable program or batch file. 

I have tried multiple times to reinstall it and set it up from scratch with different guides but it just won't work.

This is what the bat file says

@ECHO OFF
SET BIN_TARGET=%~dp0/./wp-cli.phar
php %BIN_TARGET% %*

This is the environment variable i am using to point it to the bat file

That is where the .phar file and my .bat file are located to run the CLI.

All help is appreciated

Regards

Jonas Bang

Topic wp-cli command-line windows Wordpress

Category Web


Currently i have several process running in my CI/CD with wp-cli and all works fine in windows and unix. In my experience this is your best option in windows:

#1 Add PHP to your Windows Path Variable

#2 Install, as @Rup suggests, Git-bash terminal.

#3 Execute an wp-cli command like that:

vendor/bin/wp cache flush --path=public/wp-cms/wp-core

*This code consider you are using wp-cli managed with composer, and the files are locatted at vendor folder, otherwise you can replace vendor/bin/wp with wp

enter image description here

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.