private bool RegisterUrl(int portNumber) { try { var startInfo = new ProcessStartInfo() { FileName = "netsh.exe", Arguments = string.Format("http add urlacl http://*:{0}/ user=EVERYONE", portNumber) }; var process = _processProvider.Start(startInfo); process.WaitForExit(5000); return(true); } catch (Exception ex) { Logger.WarnException("Error registering URL", ex); } return(false); }
public void StartServer() { Logger.Info("Preparing IISExpress Server..."); var startInfo = new ProcessStartInfo(); startInfo.FileName = _environmentProvider.GetIISExe(); startInfo.Arguments = String.Format("/config:\"{0}\" /trace:i", _environmentProvider.GetIISConfigPath()); startInfo.WorkingDirectory = _environmentProvider.ApplicationPath; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.CreateNoWindow = true; startInfo.EnvironmentVariables[EnvironmentProvider.NZBDRONE_PATH] = _environmentProvider.ApplicationPath; startInfo.EnvironmentVariables[EnvironmentProvider.NZBDRONE_PID] = Process.GetCurrentProcess().Id.ToString(); try { _configFileProvider.UpdateIISConfig(_environmentProvider.GetIISConfigPath()); } catch (Exception e) { Logger.ErrorException("An error has occurred while trying to update the config file.", e); } var iisProcess = _processProvider.Start(startInfo); IISProcessId = iisProcess.Id; iisProcess.OutputDataReceived += (OnOutputDataReceived); iisProcess.ErrorDataReceived += (OnErrorDataReceived); iisProcess.BeginErrorReadLine(); iisProcess.BeginOutputReadLine(); ServerStarted = true; iisProcess.EnableRaisingEvents = true; iisProcess.Exited += IIS_EXITED; }