Created
August 5, 2016 15:01
-
-
Save nvivo/59c81b106132a9f928f9a7314def15c5 to your computer and use it in GitHub Desktop.
Start IIS Express from Here and open the browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\IISExpress] | |
@="IIS Express Here" | |
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\IISExpress\command] | |
@="D:\\Bin\\StartIISExpress.exe %V" | |
[HKEY_CLASSES_ROOT\Directory\Background\shell\IISExpress] | |
@="IIS Express Here" | |
[HKEY_CLASSES_ROOT\Directory\Background\shell\IISExpress\command] | |
@="D:\\Bin\\StartIISExpress.exe %V" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Threading; | |
namespace StartIISExpress | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var path = args.Length > 0 ? args[0] : Environment.CurrentDirectory; | |
var rnd = new Random(); | |
var port = rnd.Next(1024, 65535); | |
var psi = new ProcessStartInfo | |
{ | |
WorkingDirectory = "C:\\Program Files (x86)\\IIS Express", | |
FileName = "iisexpress.exe", | |
Arguments = $"/port:{port} /path:\"{path}\"", | |
UseShellExecute = true | |
}; | |
Process.Start(psi); | |
Thread.Sleep(500); | |
Process.Start($"http://localhost:{port}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment