I have a system for monitoring and monitoring users and would like to block a site using Delphi or even MSDOS or VBS commands, or even using Sockets (I do not know if it's possible)? What I have for now is this:
Delphi
var
dd: TextFile;
begin
if FileExists('\Windows\system32\drivers\etc\hosts') then
begin
AssignFile(dd,'\Windows\system32\drivers\etc\hosts');
ReSet(dd);
Append(dd); // aqui ocorre "File access denied"
if IOResult = 0 then
begin
WriteLn(dd,'127.0.0.1 www.meusite.com');
CloseFile(dd);
end;
end;
VBS
dim Fso,f
Dim rep,label,titre,defaut,data
label="Escreva a URL que deseja bloquear"
defaut=""
titre="Bloquear Sites"
rep=InputBox(label,titre,defaut)
Set Fso = CreateObject("Scripting.FileSystemObject") ' aqui dá "Acesso negado"
sys32=Fso.GetSpecialFolder(1)
Set f = fso.OpenTextFile(sys32+"\DRIVERS\ETC\hosts", 8)
if rep="" then Cleanup
f.Write vbnewline
f.Write "127.0.0.1 " &rep
Sub Cleanup()
Set FSO = Nothing
WScript.Quit
End Sub