4
I have a user control and monitoring system and would like to block a site using Delphi or even MSDOS or vbs commands, or even using Sockets(I don’t know if it’s possible)? What I have so far 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
Do you want to create a proxy, a large application? Or just a "script"?
– durtto
One script only. It’s for a user control system on a PC.
– Grégori Sória
What’s wrong with this code you posted?
– durtto
What you really need?
– durtto
I need to find a way to block a site (read the title again), in Delphi, msdos or vbs (not VB.net). The post q code (if you read it) you must have seen that the two give error "access denied".
– Grégori Sória
@Does Vaati give denied access to edit? If that’s why you have to run the application as an administrator
– Guilherme Nascimento