Skip to content

Instantly share code, notes, and snippets.

@jacksonfdam
Last active December 23, 2015 23:29
Show Gist options
  • Save jacksonfdam/6710742 to your computer and use it in GitHub Desktop.
Save jacksonfdam/6710742 to your computer and use it in GitHub Desktop.
A windows batch file to automate my tasks with projects. Just save in yours project server root and run in comand line: newproject.bat www.myproject.com I use EasyPHP, but feel free to customize the script and share.
@ECHO OFF & setLocal enabledelayedexpansion
TITLE CREATE A NEW PROJECT
COLOR F0
::location of vhosts
SET BASEURL=E:\www\
SET WINBASEURL=E:/www/
IF %1.==. GOTO No1
IF EXIST %BASEURL%%1 ECHO The specified site folder already exists! Choose another.
IF EXIST %BASEURL%%1 GOTO No1
SET NEWLINE=^& ECHO.
FIND /C /I "%1" %WINDIR%\system32\drivers\etc\hosts
:: IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%>>%WINDIR%\system32\drivers\etc\hosts
:: IF %ERRORLEVEL% NEQ 0 ECHO 127.0.0.1 %1>>%WINDIR%\system32\drivers\etc\hosts
ECHO %NEWLINE%>>%WINDIR%\system32\drivers\etc\hosts
ECHO 127.0.0.1 %1>>%WINDIR%\system32\drivers\etc\hosts
ECHO %NEWLINE%>>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE%#%1# >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE%^<VirtualHost %1^> >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% DocumentRoot "%WINBASEURL%%1" >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% ServerName %1 >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% ServerAlias %1 >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% ^<Directory "%WINBASEURL%%1"^> >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% Options Indexes FollowSymLinks Includes ExecCGI >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% Order allow,deny >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% Allow from all >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% ^</Directory^> >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
ECHO %NEWLINE% ^</VirtualHost^> >>"C:\Program Files\EasyPHP-5.3.9\conf_files\httpd.conf"
GOTO End1
:No1
ECHO No param sitename
GOTO End1
:End1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment