• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP Bitz

A curated collection of code snippets for WordPress

  • Home
  • About
  • Blog
  • Code Snippets
You are here: Home / Code Snippets / Batch file to remove WordPress site in XAMPP

Batch file to remove WordPress site in XAMPP

November 8, 2022

This post brought to you by RocketGeek, ButlerBlog, and the following:

 

:: PHP, WP-CLI, and MYSQL all need to be path environment variables.
:: If you get errors that indicate something is not recognized as an internal
:: or external command, make sure you have these in your PATH.

@echo off

:: Start in the XAMPP folder, assumes XAMPP is in the root
:: (use PUSHD to get into the dir instead of "cd" so we can use POPD to get back into the original dir).
PUSHD "C:/XAMPP/htdocs"

:: Ask for package folder.
set /p wp_name=WP site to remove: 

:: Delete folder in XAMPP directory.
echo Deleting %wp_name% folder
@RD /S /Q %wp_name%

:: Delete Database and users (uses MySQL CLI)
echo Deleting db user 
call mysql -e "DROP USER '%wp_name%'@'localhost';" -u root
call mysql -e "FLUSH PRIVILEGES;" -u root 
echo Deleting database %wp_name%
call mysql -e "DROP DATABASE %wp_name%;" -u root

echo Done remvoing WordPress site %wp_name%.

:: Go back to original folder (when using PUSHD to get into the dir, POPD takes us back).
POPD

@pause

Chad Butler

Primary Sidebar

Join for free!

Get free code snippets, WordPress best practices, and practical Content Marketing advice from seasoned WordPress expert Chad Butler (butlerblog):

Recent Posts

  • Bitnami WordPress Autoptimize cannot write to the cache directory
  • Create and delete WordPress sites in XAMPP with a batch file
  • How to fix “Error: MySQL Shutdown Unexpectedly” in XAMPP control panel
  • Fix missing Customizer in WordPress 6
  • Use Proofy.io API to validate WordPress registrations

Copyright © 2023 · Maker Pro on Genesis Framework · WordPress · Log in