:: 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
Batch file to remove WordPress site in XAMPP
This post brought to you by RocketGeek, ButlerBlog, and the following: