Skip to content

Instantly share code, notes, and snippets.

@joshuaflanagan
Created January 16, 2011 15:39
Show Gist options
  • Save joshuaflanagan/781893 to your computer and use it in GitHub Desktop.
Save joshuaflanagan/781893 to your computer and use it in GitHub Desktop.
Launch IIS Express from the command line
@ECHO OFF
SET IIS="c:\Program Files (x86)\IIS Express\iisexpress.exe"
SET ARG=%1
REM Default to curret directory if no path provided
IF [%ARG%] == [] (
SET root=%CD%
GOTO launch
) ELSE (
SET CHECKPARAM=x%ARG%x
IF %CHECKPARAM:~1,1% == / (
SET root=%CD%
GOTO launch
) ELSE SHIFT
)
REM Strip any quotes around path
FOR /f "useback tokens=*" %%a in ('%ARG%') DO SET ARG=%%~a
REM Make the path absolute
IF %ARG:~1,1% == : (SET root=%ARG%) ELSE (
IF %ARG:~0,1% == \ (SET root=%CD:~0,2%%ARG%) ELSE (SET root=%CD%\%ARG%)
)
:launch
IF NOT EXIST %root% (
ECHO Invalid path: %root%
GOTO :EOF
)
START "IIS Express - %root%" CMD /C "%IIS% /path:"%root%" %1 %2 %3 %4 %5 %6 %7 %8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment