public
Last active

IISExpress runner

  • Download Gist
IISExpress runner
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// 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);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.