WCF selfhosted service, installer class and netsh

Posted by jeho on Stack Overflow See other posts from Stack Overflow or by jeho
Published on 2010-03-26T08:40:02Z Indexed on 2010/03/26 8:43 UTC
Read the original article Hit count: 667

Filed under:
|
|

I have a selfhosted WCF service application which I want to deploy by a msi installer package. The endpoint uses http port 8888. In order to startup the project under windows 2008 after installation I have to either run the program as administrator or have to edit the http settings with netsh:

"netsh http add urlacl url=http://+:8888/ user=\Everyone"

I want to edit the http settings from my installer class. Therefore I call the following method from the Install() method:

    public void ModifyHttpSettings()
    {
        string parameter = @"http add urlacl url=http://+:8888/ user=\Everyone";

        System.Diagnostics.ProcessStartInfo psi =
            new System.Diagnostics.ProcessStartInfo("netsh", parameter);

        psi.Verb = "runas";
        psi.RedirectStandardOutput = false;
        psi.CreateNoWindow = true;
        psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        psi.UseShellExecute = false;
        System.Diagnostics.Process.Start(psi);
    }

This method will work for english versions of windows, but not for localized versions (The group Everyone has different names in localized versions). I have also tried to use Environment.UserName to allow access at least for the current logged on user. But this does also not work, because the installer class is run by the msi service which runs under the user SYSTEM. Hence Enviroment.UserName returns SYSTEM and that is not what I want.

Is there a way to grant access to all (or at least for the current logged on) user to my selfhosted WCF service from a msi installer class?

© Stack Overflow or respective owner

Related posts about msi

Related posts about wcf