Skip to content

Instantly share code, notes, and snippets.

@duncansmart
Created March 10, 2011 15:56
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save duncansmart/864322 to your computer and use it in GitHub Desktop.
Save duncansmart/864322 to your computer and use it in GitHub Desktop.
IISExpress runner
// Runs IIS Express without a console window (if started with wscript.exe)
var sitePort = 8080
var sitePath = "."
var siteClr = "v4.0"
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wshell = new ActiveXObject("WScript.Shell")
// Resolve path
sitePath = fso.GetAbsolutePathName(sitePath);
// look for IISExpress
var iisexpress = wshell.ExpandEnvironmentStrings("%ProgramFiles%\\IIS Express\\iisexpress.exe");
if (!fso.FileExists(iisexpress)) {
iisexpress = wshell.ExpandEnvironmentStrings("%ProgramFiles(x86)%\\IIS Express\\iisexpress.exe");
if (!fso.FileExists(iisexpress)) {
WScript.Echo("Couldn't find IIS Express. Install using the Web Platform Installer.");
WScript.Quit(1);
}
}
// launch browser
wshell.Run('http://localhost:' + sitePort, 1, false);
// start IISExpress hidden and wait for exit
wshell.Run('"' + iisexpress + '" /port:' + sitePort + ' /clr:' + siteClr + ' /path:"' + sitePath + '"', 0, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment