If I run these commands sequentially in windows CMD, I get a site up and running quite quickly.

wp core download
wp core config --dbname=my_wp_database --dbuser=root --dbpass=my-db-password
wp core install --url=http://localhost/my-site-url --title="My WP Site" --admin_user=admin --admin_password=admin [email protected]

I'd love to make this even easier with a one-click script.

My attempt is below. It "nearly" works, but there are display issues on the resulting site.

Can anyone please give me a tweaked version that works properly and allows for spaces in the site name?


@echo off
set sitename="My Lovely Site"
set dbname="my_db_name"
mkdir %sitename%
cd %sitename%
start /wait wp core download
call wp core config --dbname=%dbname% --dbuser=root --dbpass=my_db_password
call wp core install --url=http://localhost/%sitename% --title=%name% --admin_user=admin --admin_password='admin' [email protected]

PS I'm aware this question is as much about Windows batch scripting as WP development, but I imagine a script like this would be of use to many WP developers so I'm posting here.

  • you dhould try to put quotes around whatever might contain spaces. If it needs escaping for whatever reason, probably best to ask on SO, I would assume not many doing much windows scripting around here. Sep 9, 2017 at 16:31

1 Answer 1


This is the script I use on Windows under XAMPP. It includes a MySQL command to create the database, and a tweak to improve security by nuking user 1 (and all its content) straight after install, resulting in a clean empty database.

@echo off
set dbName="wp_yourdbname"
set dbPass="your_random_db_password"
set siteUrl="sitename.localdev.yourdomain.com"
set siteName="Kluwell"
set siteDesc=""
set adminUser="Second User Name"
set adminPass="admin_password"
set adminEmail="[email protected]"
:: these get nuked straight after install
set adminUserDummy="admin"
set adminUserDummyEmail="[email protected]"

SET /P AREYOUSURE=This will nuke the current site %siteUrl% and the DB %dbName%. Are you sure (Y/[N])?

REM SQL setup
mysql -u root -p -e "DROP USER IF EXISTS %dbName%@localhost;DROP DATABASE IF EXISTS %dbName%;CREATE USER %dbName%@localhost IDENTIFIED BY '%dbPass%';CREATE DATABASE IF NOT EXISTS %dbName%; GRANT ALL PRIVILEGES ON %dbName% . * TO %dbName%@localhost;exit;"

REM setup core
call wp core download
call wp core config --dbname=%dbName% --dbuser=%dbName% --dbpass=%dbPass%
call wp core install --url=%siteUrl% --title=%siteName% --admin_user=%adminUserDummy% --admin_password=%adminPass% --admin_email=%adminUserDummyEmail%

REM remove first user
call wp user create %adminUser% %adminEmail% --role=administrator --user_pass=%adminPass%
call wp user delete 1 --yes 

Works a treat, especially if you set up a wildcard DNS entry to point *.localdev.yourdomain.com to and configure mod_vhost_alias under Apache so that you can serve all the localdev sites out of a single directory, one subdir per host, so creating a subdirectory of dave equates to a url of dave.localhost.yourdomain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.