Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Last active January 5, 2016 13:35
Show Gist options
  • Save dieseltravis/1181245 to your computer and use it in GitHub Desktop.
Save dieseltravis/1181245 to your computer and use it in GitHub Desktop.
Add a shortcut to your Send To menu to launch a folder in IISExpress
@echo off
:: normalize folder
SET folder=%~1
IF %folder:~-1%==\ SET folder=%folder:~0,-1%
:: random number from 8000 to 9999
SET /a port=(%random%)*1999/32767+8000
:: start the web server for the random port starting at the passed-in directory
start "IIS Express :%port%" cmd /C " "%ProgramFiles%\IIS Express\iisexpress.exe" /path:"%folder%" /port:%port% /systray:true "
:: launch the browser pointing to this location
start http://localhost:%port%/
:: To use in Send To: drag a shortcut to this batch file to %APPDATA%\Microsoft\Windows\SendTo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment