Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VB.NET
hello !
i am working on a small application ,through which i can block any website on my computer , means if i want to block youtube or yahoo at my computer then no one can able to visit them using any webbrowser , is this possible in vb.net or in c#
 
Regards
Posted 26-Jul-12 19:08pm
badbaoy472
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

here is full code
 

Public Function IPAdress(ByVal CompName As String) As String
myIPs = System.Net.Dns.GetHostByName(CompName)
For Each myIP As System.Net.IPAddress In myIPs.AddressList
add = myIP.ToString
Next
Return add.ToString
End Function
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        Blocked()
    End Sub
    Sub Blocked()
        IO.File.AppendAllText("\\" & HostName.ToString.Trim & "\C$\windows\system32\drivers\etc\hosts", vbNewLine & IPAdress(HostName).ToString & vbTab & TextBox2.Text.Trim)
        Load_BlockedSites()
        MessageBox.Show("Site Blocked")
  End Sub
 

thanks and Regards
sarva
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I would say: don't do evil. And please don't tell me that you have this feature as a requirement; I don't care.
 
You can do it only if you assume that the person installing this "tool" has more advanced privileges than a user. In what settings it could be the case? In all companies I ever knew all employees always get administrative privileges for their local systems on first request. If this is not the case — everything you can block on my computer I can unblock.
 
—SA
  Permalink  
v2
Comments
badbaoy at 31-Jul-12 10:57am
   
well Sergey Alexandrovich .i dont need any type of suggestion from you . i asked a simple question if you have proper answer then give it if you dont have any solution for this prob then please do not tell me what to do .
and by the way who you are to unblock everything on my computer :P , well i dont want to use any harsh word for you :P because i think there is nothing to say for fools :P.
I am working on a simple computer lab management application , this application has LAN chat , Usb Blocking , and Site restrictions.
 
Regards
Sergey Alexandrovich Kryukov at 31-Jul-12 11:46am
   
I would I care if you need it or not? This is pretty rude of you. You asked for an advice; and this is enough for me. And by the way, 1) this is a really good advice, a practical one, but it takes some understanding; 2) I actually answered you "simple" question in second paragraph, and this is the only valid thing about it.
 
You should have some logic to understand that a negative solution is still a solution. You aren't a kid who would cry about a toy he cannot get, aren't you?
 
I know that this is useless, but calling me a fool and maintaining that you don't want harsh words is just funny. It is very usual that such rudeness is only possible in extremely incompetent and illiterate people. Welcome to the club!
 
--SA
@AmitGajjar at 12-Jun-13 8:32am
   
Hi SA,
Although this is very old post but actually i have similar functionality to achieve. In my case, i have shared internet from my server to other computers. I want to restrict all other computers to access on community site. Can i filter all incoming request from client computers from server using c# ?
 
Thanks
-Amit
Sergey Alexandrovich Kryukov at 12-Jun-13 13:08pm
   
I don't see how it is similar, only remotely. Basically, your requirements may have sense, but one by OP — hardly. I think you can only filter out access by IP, as your server receive client IP, or, of course, by authorization. IP is absolutely reliable, but this is a shaky matter: most users won't have static IPs. Very often, IP will be assigned dynamically:
 
http://en.wikipedia.org/wiki/Dynamic_IP#Dynamic_IP
 
It means, the same user may have different IPs: due to dynamic assignment, or due to the fact the same person can access the site from different computers or move a computer from one network to another. With WiFi, for example, it may happen all the time. And, due to dynamic assignment, different user can get the same IP.
 
Now, if all your users are from the same organization with more or less well-defined administration, you can set it up with network administrators, to filter IPs by some allowed subset of addresses. I don't know, it will depend on your organization's setting. Consult those people, they can set up you a solution based on this idea: they will guarantee that your organization users will get some certain IP subset, and you will put it in your configuration. Does it make sense to you?
 
—SA
@AmitGajjar at 13-Jun-13 0:13am
   
Thanks for your detailed explanation. Certainly you are correct. For big organization they can afford IT Administrator who could setup server and maintain on daily basis. In my case we have so many small firms who could not hire them. So i suggest them to develop a software that can be integrated in their existing software and it can do filtration of some porn sites. Please suggest some solution so i can integrate in the existing C# application. I can add one menu in the application where company head can add restricted sites very easily from the proxy computer. Hope you got some idea about my problem.
 
Thanks again for your effort.
-Amit
Sergey Alexandrovich Kryukov at 13-Jun-13 0:20am
   
I would suggest you formulate it as a separate questions. I have a little concern with network administration issues (and I even against any thinkable limitations in Internet usage). Filtering is very different from what we discussed so far and I think is much simpler. You will be able to find a lot of solutions if you Google.
—SA
@AmitGajjar at 13-Jun-13 0:23am
   
No problem. Thanks you very much SA.
 
I will try my best from Google/MSDN :)
@AmitGajjar at 13-Jun-13 0:24am
   
i have one question. are you slipping or not. All the time i can see you online in the codeproject ;)
Sergey Alexandrovich Kryukov at 13-Jun-13 0:28am
   
Come on, this is just the illusion...
—SA
@AmitGajjar at 13-Jun-13 0:32am
   
I don't think so. I think you are very passionate about helping people so this all your work is like fun for you.
 
I really would like to thank you for all your contributions.
 
-Amit
Sergey Alexandrovich Kryukov at 13-Jun-13 1:17am
   
Thank you for your nice words, Amit.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Add ur sites url programatically in hosts file, which is located in C:\WINDOWS\system32\drivers\etc
 
some code here
 
IO.File.AppendAllText("\\" & HostName.ToString.Trim & "\C$\windows\system32\drivers\etc\hosts", vbNewLine & IPAdress(HostName).ToString & vbTab & TextBox2.Text.Trim)
thanks and regards
 
Sarva
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 27 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid