This site has been generated and deployed from Github repository tjtharrison/

Tim Harrison

DevSecOps Team Lead

Using a Batch file to swap between dev and live versions of a Website

This was required for one of my Customers who required being able to swap between the dev version and live version of their site from Windows – While the licensing for their site required the URL to be the same.

@echo off

SET NEWLINE=^& echo.

FIND /C /I "" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^>>%WINDIR%\System32\drivers\etc\hosts

start ""

@ECHO off
SET "HOSTS=%WinDir%\System32\drivers\etc\hosts"
COPY /b/v/y "%TEMP_HOSTS%" "%HOSTS%"

start ""