Hello Everyone:
I have an application to append a line to the hosts file. And I use it very often when I find a misleading or aggresive website.
When I made it originally on VB6 and XP it worked OK, then I copied it to a Vista computer and it works fine, except that it asks for permission to elevate it's rights.
Now I remade it with VB2008 Express and Vista, and tried different ways with external or embeded manifest file and It doesn't work the way I would like:
If I don't specifically start it with run as administrator, it loads, but fails to write to the hosts file, so to avoid the error I made a try catch section with a message to the user about running it as administrator, but I think this is a waste of time; if I forget to start it the proper way, you have to start it twice.
Is there a way to mark the file so, when you call it, the system knows in advance that it requires administrator permit, and asks you for it instead of running and failing?
Any help is appreciated.
Ricardosms
18 Replies - 8703 Views - Last Post: 15 April 2012 - 09:22 AM
Replies To: Mark Application As Needing Administrator Rights
#2
Re: Mark Application As Needing Administrator Rights
Posted 22 June 2010 - 10:49 AM
Here's a good write up on this: Banish UAC Issues
#3
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 05:16 AM
Thasnk You Psychocoder,
that was helpful and interesting. I found some ideas to try later.
My solution is to spawn a second instance of the application with elevated rights and, if successful, close first instance. There are a button and a label that replace each other if the user has administrative rights or not. At load it checks the access rights using a code from RodgerB on this site:
[Link]
http://www.dreaminco...snippet1558.htm
[/Link]
and acts accordingly. If the user has the proper rights the button is invisible, otherwise he can click it to get elevated rights.
Here is my application attached if someone wants to check and comment on it.
Ricardosms.
Mark Application As Needing Administrator Rights.zip (61.99K)
Number of downloads: 126
that was helpful and interesting. I found some ideas to try later.
My solution is to spawn a second instance of the application with elevated rights and, if successful, close first instance. There are a button and a label that replace each other if the user has administrative rights or not. At load it checks the access rights using a code from RodgerB on this site:
[Link]
http://www.dreaminco...snippet1558.htm
[/Link]
and acts accordingly. If the user has the proper rights the button is invisible, otherwise he can click it to get elevated rights.
Here is my application attached if someone wants to check and comment on it.
Ricardosms.
Mark Application As Needing Administrator Rights.zip (61.99K)
Number of downloads: 126
#4
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 09:26 AM
Why should your application have administrative rights?
#5
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 09:59 AM
A little cynical are we AdamSpeight2008?? 
I've written applications that have needed Admin rights to do some of the work, like registry work and such, so it's not that shocking to me that someone asked how to do it. There are just times when an application needs to run as Administrator
I've written applications that have needed Admin rights to do some of the work, like registry work and such, so it's not that shocking to me that someone asked how to do it. There are just times when an application needs to run as Administrator
#6
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 12:23 PM
AdamSpeight2008, on 23 June 2010 - 08:26 AM, said:
Why should your application have administrative rights?
Hello AdamSpeight2008, On my computer (Vista Home), "../drivers/etc" is a system folder. If I am not administrator I can't create/copy to/modify/delete files... The system won't allow me. I don't know how other people set their systems, but I believe mine is at the default configuration.
Regards,
Ricardo.
#7
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 12:33 PM
Well that leads me to ask why would you need to be doing anything in the system folders? Normally only things like spyware, malware & viruses fiddle around in the system folders. So now you have me wondering what you're up to
#8
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 01:50 PM
Hi Psychocoder:
If you read my original post you already know. I am appending to the hosts file the address of offending web sites.
I have downloaded hosts files from services on the internet and, as you might know, they don't cover everything. So I want to include my own. Some times I click on a link that looks promissing and it's only an advertissing site or another search engine; some times an script don't let you go back or some sites or want you to install their sofware and the only way to close their window is to shut off the explorer, even with "Alt+F4", so I keep them out.
Regarding your other concern, to get the elevation of rights still requires your consent, because the screen will come in fron of you, it doesn't do it quietly. I just don't need to close my program and start again. It will start a second one after my approval and then close the first one. So I am not bypassing the security, I am just making things easier for myself if I forget to right click on the "runas".
Is that fair?
Regards,
ricardosms.
If you read my original post you already know. I am appending to the hosts file the address of offending web sites.
I have downloaded hosts files from services on the internet and, as you might know, they don't cover everything. So I want to include my own. Some times I click on a link that looks promissing and it's only an advertissing site or another search engine; some times an script don't let you go back or some sites or want you to install their sofware and the only way to close their window is to shut off the explorer, even with "Alt+F4", so I keep them out.
Regarding your other concern, to get the elevation of rights still requires your consent, because the screen will come in fron of you, it doesn't do it quietly. I just don't need to close my program and start again. It will start a second one after my approval and then close the first one. So I am not bypassing the security, I am just making things easier for myself if I forget to right click on the "runas".
Is that fair?
Regards,
ricardosms.
#9
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 04:34 PM
You cannot block websites by editing the host file.
This file contains the mappings of IP addresses to host names.
Even if you assign ip 127.0.0.1 to the website you want to block, you can still access the site by just entering the ipaddress of the website.
This file contains the mappings of IP addresses to host names.
Even if you assign ip 127.0.0.1 to the website you want to block, you can still access the site by just entering the ipaddress of the website.
#10
Re: Mark Application As Needing Administrator Rights
Posted 23 June 2010 - 05:42 PM
Searock, on 23 June 2010 - 03:34 PM, said:
You cannot block websites by editing the host file.
This file contains the mappings of IP addresses to host names.
Even if you assign ip 127.0.0.1 to the website you want to block, you can still access the site by just entering the ipaddress of the website.
This file contains the mappings of IP addresses to host names.
Even if you assign ip 127.0.0.1 to the website you want to block, you can still access the site by just entering the ipaddress of the website.
Hi Searock:
What you say might be correct, but who knows on top of his head the ip address of every website. When I want to check my emails I type www.hotmail.com , I don't type an IP address. When I exit my IE session and start another and try to go to a website that is in the hosts file my explorer takes me to a page that says:
Navigation Was Cancelled
You can try:
retype the address.
Or, if I am clicking on a link, It will say "Internet explorer cannot open the web site" and them asks you to try few things: Navigate back, make sure there is a internet connction or to retype the address...
Isn't it this way?
If it is not, then, what is the purpouse of the hosts file?
I am not trying to lecture you, but, am I the only person that surfs the internet and bumps on these places?
Regarding the former replay. A follow up...
Open 'notepad.exe' or 'wordpad.exe' by double clicking on them, not right clicking. Navigate to the hosts file and edit it and try so save it back. What will the system say? Or try to write a file to that folder with a normal application or a windows explorer drag and drop or copy-paste. Will it allow it without protesting? Or will it ask for your credentials?
Am I wrong?
I think to edit the hosts file, to put a DLL in the system32 folder, to write to the registry or to copy a file to the c:'s root directory are all legitimate uses.
Regards,
ricardosms.
This post has been edited by ricardosms: 24 June 2010 - 11:23 AM
#11
Re: Mark Application As Needing Administrator Rights
Posted 24 June 2010 - 11:15 AM
Searock, on 23 June 2010 - 03:34 PM, said:
You cannot block websites by editing the host file.
This file contains the mappings of IP addresses to host names.
Even if you assign ip 127.0.0.1 to the website you want to block, you can still access the site by just entering the ipaddress of the website.
This file contains the mappings of IP addresses to host names.
Even if you assign ip 127.0.0.1 to the website you want to block, you can still access the site by just entering the ipaddress of the website.
Hello again Searock:
I had a second thought on what you said and I would like to comment further. Probably I didn't use the proper term when I said to 'block' a website, but I want to mention this:
Mapping probably is the technical name to what the hosts file does, but to me there is nothing like a mapping, I think it is more like a lookup table whith 3 columns:
Forst one: an IP address that I believe is inside my computer and is always 127.0.0.1.
Second one: The names of websites.
Third one: comments.
The comments are ignored, the second one is a table where you compare the typed address on your web browser with the names stored there. And then, if the name is found, the webbrowser is redirected to what the first column shows. It is like the old "NULL" from the PC-DOS and MS-DOS, where you could redirect the output of a DOS program if you didn't need it or you didn't want it. Or like in my home, there used to be 8 people living here, and everyone had a different name, everybody was receiving letters, but all of them were put in the same box by the mailman. Hosts file is a dictionary with several words with only one meaning.
Probably instead of 127.0.0.1 I could use some other number, but I only have seen it this way. I don't remember reading my original host file when I bought my computer with Vista Installed, but I remember the one that came with XP, and it was only about 5 or 6 lines long with some information and one example. So I believe it was there just like a place keeper and it needed to be edited or replaced.
Regarding the blocking of the site, why should I go through the problem of looking up and typing the IP of a site where I don't want to go? You are assumming the opposite of what I ask.
Anyway, I know you are not here to make any money by taking the time to to reply me or to share your knowledge or points of view, and you could, as well, ignore me. So thank you very much.
Ricardosms
#12
Re: Mark Application As Needing Administrator Rights
Posted 26 June 2010 - 02:53 PM
Hello:
Just a tip to the 2 people that downloaded my code,
You have to build the sample because it calls itself with wathever name you might have renamed it to, and if you run it on the environment it will call the "svhost.exe" program and just exit.
Regards,
ricardosms.
Just a tip to the 2 people that downloaded my code,
You have to build the sample because it calls itself with wathever name you might have renamed it to, and if you run it on the environment it will call the "svhost.exe" program and just exit.
Regards,
ricardosms.
#13
Re: Mark Application As Needing Administrator Rights
Posted 15 September 2010 - 04:14 PM
I don't understand how putting an entry into the hosts file will block malicious sites. I test websites on different servers at work. When I want to test a particular server, for example, I point to one of the Qualtiy (test) servers by putting an entry (eg. 11.5.61.182 www.website.com - not a real example, just to demonstrate). This means that I will ACCESS that server only. When I want to revert back to the Production (live) servers, I just put a "#" (without the quotes) in front of the IP address (after closing all open browsers), save the hosts file, open my browser, navigate to the website, and then I will be on the Production Servers when I access the website. I saw a host entry on someone's computer WITHOUT the "#" sign and the website said www.youtube.com. I "Googled" the IP address and the results showed (which I didn't click on, just read the Google search results) it WAS NOT YOUTUBE. This person's computer had some performance issues and I wonder if the host file entry allowed for malware to infect the computer. Can someone please explain this to me? Am I wrong, confused, what? lol. Thanks
#14
Re: Mark Application As Needing Administrator Rights
Posted 10 October 2010 - 05:56 AM
CodeWomanSRQ1234, on 15 September 2010 - 03:14 PM, said:
I don't understand how putting an entry into the hosts file will block malicious sites. I test websites on different servers at work. When I want to test a particular server, for example, I point to one of the Qualtiy (test) servers by putting an entry (eg. 11.5.61.182 www.website.com - not a real example, just to demonstrate). This means that I will ACCESS that server only. When I want to revert back to the Production (live) servers, I just put a "#" (without the quotes) in front of the IP address (after closing all open browsers), save the hosts file, open my browser, navigate to the website, and then I will be on the Production Servers when I access the website. I saw a host entry on someone's computer WITHOUT the "#" sign and the website said www.youtube.com. I "Googled" the IP address and the results showed (which I didn't click on, just read the Google search results) it WAS NOT YOUTUBE. This person's computer had some performance issues and I wonder if the host file entry allowed for malware to infect the computer. Can someone please explain this to me? Am I wrong, confused, what? lol. Thanks
Hi, CodeWomanSRQ1234
I see that no expert replied to your post, and because I initiated this thread, I will give you my humble undestanding of how it works:
When you click on a link or type a webpage name (not an IP)
IE:
www.hackersandadvertisers.hu
or:
theworstsiteforvirus.com
the system looks on some places in your computer, one of them is the hosts file.
if hackersandadvertisers.hu is found, then your browser will navigate to the IP that is shown on the left of that entry, otherwise it will navigate normaly to your link or address.
An entry on the hosts file is similar to this:
127.0.0.1 www.freelancer.com # Apr 27 2010 @ 05:09 PM
On Bold is the link where you intend to go,
Underlined is the place where you actually go.
After the "#" character are only comments.
If www.freelancer.com was not on your hosts file your browser would take you there.
Please check my other post titled "hosts", where "no2pencil", posts an entry.
I hope this clarifies it a bit.
ricardosms
#15
Re: Mark Application As Needing Administrator Rights
Posted 23 January 2011 - 06:53 AM
Hello:
Just a little note.
When you update or install an antivirus the hosts file properties may be changed to read only. So check that. You may need to change it back in order to append.
regards,
ricardosms
Just a little note.
When you update or install an antivirus the hosts file properties may be changed to read only. So check that. You may need to change it back in order to append.
regards,
ricardosms
|
|

New Topic/Question
Reply



MultiQuote






|