?
Solved

C# Edit host file programmatically

Posted on 2013-01-11
4
Medium Priority
?
3,590 Views
Last Modified: 2013-01-11
I am trying to edit the host file in Windows programaticly but keep failing.
Getting this error in VIsual Studio
{"Access to the path 'C:\\Windows\\system32\\drivers\\etc\\hosts' is denied."}

I google it and found this http://stackoverflow.com/a/10987320 but have no idea how to do that?.....I have never done that before, or if you guys have another solution?

Thanks
0
Comment
Question by:chugarah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:wvuser1
ID: 38767778
Basically what you need to do is run your programm as administrator:
http://stackoverflow.com/a/10767077/435878
0
 
LVL 1

Author Comment

by:chugarah
ID: 38767859
Nice fast answer. But I am not sure if that will solve my issue?

The program will autostart everytime the computer starts and sometimes users that doesnt have any admin rights will use it, is it possible to write the host file without UAC box?, this is supose to run in the background.
0
 
LVL 2

Accepted Solution

by:
wvuser1 earned 2000 total points
ID: 38767897
Well then that sounds more like system service than a program.
http://stackoverflow.com/a/4640118/435878
0
 
LVL 1

Author Closing Comment

by:chugarah
ID: 38767940
Now we are talking :) Thanks, nice
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question