I am trying to distribute IIS Express with my application. IIS Express will serve external web requests on port 80.
I have no problems running IIS Express as well as
Try this. We had the same situation and this worked. This may help you.
This is with IIS Express 7.5 which does not need Administrator rights.
string IIS_EXPRESS = @"C:\Program Files\IIS Express\iisexpress.exe";
StringBuilder arguments = new StringBuilder();
arguments.Append(@"/path:");
arguments.Append(@"C:\Inetpub\wwwroot\ClientSyncService");
arguments.Append(@" /Port:2000");
Process process = Process.Start(new ProcessStartInfo()
{
FileName = IIS_EXPRESS,
Arguments = arguments.ToString(),
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
});
There was a similar question (running iisexpress without console window) on iis.net forums. Please take a look at http://forums.iis.net/p/1175262/1970513.aspx#1970513
It can't be done if you also want to use Port 80.
The answer like: string IIS_EXPRESS = @"C:\Program Files\IIS Express\iisexpress.exe";
StringBuilder arguments = new StringBuilder();
arguments.Append(@"/path:");
arguments.Append(@"C:\Inetpub\wwwroot\ClientSyncService");
arguments.Append(@" /Port:2000");
Process process = Process.Start(new ProcessStartInfo()
{
FileName = IIS_EXPRESS,
Arguments = arguments.ToString(),
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
});
Should work, however the trick is that you need to grant ACLs for the the identity of the service so that it can take ownership of port 80. In other words, during your setup program (assuming you have an MSI that will run elevated), make it run a command line like: netsh http add urlacl url=http://WhateverMachineName:80/ user=everyone
where you can limit "everyone" to instead just a specific account under which your service will be running. When you do that, then IIS express should be able to start just fine without requiring administrator privileges.
To run IIS 7.5 as administrator, just change your code slightly to:
Process process = Process.Start(new ProcessStartInfo()
{
FileName = IIS_EXPRESS,
Arguments = arguments.ToString(),
RedirectStandardOutput = true,
UseShellExecute = true,
CreateNoWindow = true,
Verb = "runas"
});
This will also enable you to run your site on port 80.
I know this is an old post, but have you considered Microsoft's SRVANY Service Wrapper?
It installs and runs as a Windows Service (under any credentials), and launches your process in a windowsless process.
Anything you can run from a command line (or Start/Run window), you can run as a service via SRVANY:
Nice write-up at: http://www.tacktech.com/display.cfm?ttid=197