Solved

C# Edit host file programmatically

Posted on 2013-01-11
4
3,301 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
  • 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 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now