Really simple stuff which is helping me out when hosting multiple sites for development on one machine; you either pass in as parameters or specify as responses
- the directory name of your site – e.g. “D:\Dev\MySite1” would be “MySite1”
- the port number you want it on
- the site ID
and it’ll set up the site, migrate your config settings to II7 if necessary, start the new site and let you know the URL to access it.
@echo off
setlocal EnableDelayedExpansion
if [%1]==[] set /P directory="Enter name of directory/site: "
if [%2]==[] set /P port="Enter port number: "
if [%3]==[] set /P sitenum="Enter site number: "
%systemroot%\system32\inetsrv\appcmd add site /name:"%directory%" /id:%sitenum% /physicalPath:"D:\Dev\%directory%" /bindings:http/*:%port%:%computername%
%SystemRoot%\system32\inetsrv\appcmd migrate config "%directory%/"
%SystemRoot%\system32\inetsrv\appcmd start site "%directory%"
echo site "%directory%" now running at http://%computername%:%port%
if [%1]==[] (if [%2]==[] (if [%3]==[] (
pause
exit
)))
I will change this to pull the next available site ID and port number unless someone else can tell me how to do that.
And yes, this would be very easy in Powershell but I’ve not done that version either..!
Also, if you’d like to know how I managed to get Syntaxhighlighter to work nicely with batch/cmd/dos, leave a comment. There are *no* nice, simple, tutorials out there with common mistakes, so I could paste my steps in here if necessary.