Solved

C# Edit host file programmatically

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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