I want to launch and stop IIS Express services for testing purposes using the command line in my .NET application, however iisreset had no impact on my iis express servicees and I couldn't find a way to solve my problem.
The interesting thing is, this works:
but when I try to replicat exactly this in my code, the stopping of the service with the button click Q doesn't work. Here is my code:
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = false;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine("cd C:\\Program Files (x86)\\IIS Express\\");
//var applicationPath =
cmd.StandardInput.WriteLine(@".\iisexpress /path:c:\users\<User-Name>\source\repos\pinkey-depot\pinkey-Depot\ /port:62008");
_driver.Url = ("http://localhost:62008/Customers/Create");
//this should pass
Assert.True(_driver.FindElement(By.Id("EMail")).Displayed);
Assert.True(_driver.FindElement(By.Id("Firstname")).Displayed);
cmd.StandardInput.WriteLine("q"); //seems to have no effect
_driver.Url = ("http://localhost:62008/Customers/Create");
//this should fail
Assert.True(_driver.FindElement(By.Id("EMail")).Displayed);
Assert.True(_driver.FindElement(By.Id("Firstname")).Displayed);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.Kill();
I have spent quite a time on trying to fix this problem and I can't believe there is no way to do what I intend.