none
How to avoid running as administrator prompt when running a program hosting WCF? RRS feed

  • Question

  • I built a "service" program (actually just a program), and a UI program. The "service" program host an WCF service and the UI program will fetch data from the "service" program through WCF. Everything works fine except one thing: every time I (or my customer) run the "service" program, I have to use "run as administrator", otherwise the "service" program will be denied to bind an http port or tcp port by Windows 7. That is annoying. Is there anyway by setting or installation program or something else to avoid it? My goal is to distribute these 2 programs to my clients and they can just run them without having to "run as administrator" every time. Any help?

    Is it not a good way to use WCF to realize this kind of interaction between programs on same computer? Then what is the good way? Any advice?

    Thursday, July 24, 2014 3:18 PM

Answers

  • An administrator can grant a user the right to create URL reservations.  And for local IPC you should use localhost, and not the real host name.

    From the WCF Documentation:

    If a WCF service is self-hosted, HTTP or HTTPS settings are configured by using a command-line tool.

    . . .

    Configuring HTTP and HTTPS

    So something like

    netsh http add urlacl url=http://localhost:80/MyUri user=DOMAIN\user

    David


    David http://blogs.msdn.com/b/dbrowne/


    Thursday, July 24, 2014 7:54 PM
  • Hi,

    When we use the built-in HTTP bindings- they're all based on HTTP.sys, which requires rights to be granted to users to register URLs. So we need the administrator rights. If you do not want to avoid running as administrator, then the way is to assign the rights to your user using command as @davidbaxterbrowne said.

    Or you'll need to change to a different binding (netTcpBinding, Non-Http) which doesn't require special privileges to listen.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 25, 2014 3:27 AM
    Moderator

All replies

  • It's an O/S issue and not a WCF issure. The solution in the link works for Vista, Win 7 and Win 8.

    http://www.7tutorials.com/use-task-scheduler-launch-programs-without-uac-prompts

    Thursday, July 24, 2014 7:46 PM
  • An administrator can grant a user the right to create URL reservations.  And for local IPC you should use localhost, and not the real host name.

    From the WCF Documentation:

    If a WCF service is self-hosted, HTTP or HTTPS settings are configured by using a command-line tool.

    . . .

    Configuring HTTP and HTTPS

    So something like

    netsh http add urlacl url=http://localhost:80/MyUri user=DOMAIN\user

    David


    David http://blogs.msdn.com/b/dbrowne/


    Thursday, July 24, 2014 7:54 PM
  • One other thing, you can use a Windows Service to host a WCF service too.
    Thursday, July 24, 2014 9:16 PM
  • Hi,

    When we use the built-in HTTP bindings- they're all based on HTTP.sys, which requires rights to be granted to users to register URLs. So we need the administrator rights. If you do not want to avoid running as administrator, then the way is to assign the rights to your user using command as @davidbaxterbrowne said.

    Or you'll need to change to a different binding (netTcpBinding, Non-Http) which doesn't require special privileges to listen.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, July 25, 2014 3:27 AM
    Moderator
  • Hi, 

    Thank you, Amy and David. I think I will try Net.Tcp first.

    Best wishes!

    Monday, July 28, 2014 9:36 PM