DarkHo Posted June 12, 2010 Share Posted June 12, 2010 (edited) I have a code but i want the blocked sites to enter to my index.html file inte same director as the exe file how do i do that ? so when i enter the blocked site i see the index.html file While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "74.125.87.103 " & GUICtrlRead($url) & @CRLF) MsgBox(64, "Added!", GUICtrlRead($url) & " was added whit ip =>" & "74.125.87.103") EndSwitch WEnd Edited June 12, 2010 by DarkHo Link to comment Share on other sites More sharing options...
GEOSoft Posted June 12, 2010 Share Posted June 12, 2010 Something like this? $sBody = StringRegExpReplace(FileRead(@ScriptDir & "\index.html"), "(?i)(?s)(.+)(</body.+)", "$1<br />74.125.87.103 " & GUICtrlRead($url) & "74.125.87.103 " & GUICtrlRead($url) & @CRLF & "$2") $hFile = FileOpen(@ScriptDir & "\index.html", 2) Filewrite($hFile, $sBody) FileClose($hFile) ShellExecute(@ScriptDir & \index.html") George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
DarkHo Posted June 12, 2010 Author Share Posted June 12, 2010 Error on ShellExecute(@ScriptDir & \ Link to comment Share on other sites More sharing options...
Makaule Posted June 12, 2010 Share Posted June 12, 2010 (edited) because he missed ". It should be:ShellExecute(@ScriptDir & "\index.html") Edited June 12, 2010 by Makaule Link to comment Share on other sites More sharing options...
DarkHo Posted June 12, 2010 Author Share Posted June 12, 2010 Why dosent this work ? FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "http://www.mysite.com/blocke/index.html " & GUICtrlRead($url) & @CRLF) MsgBox(64, "Site Added!", GUICtrlRead($url)) Link to comment Share on other sites More sharing options...
ripdad Posted June 12, 2010 Share Posted June 12, 2010 The host file has a "read only" attribute. You have to remove it first and then write. FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "-R") --- Write to the file --- When finished set it back to read only FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "+R") "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 Why dosent this work ? FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "http://www.mysite.com/blocke/index.html " & GUICtrlRead($url) & @CRLF) MsgBox(64, "Site Added!", GUICtrlRead($url)) What doesn't work other than the wrong format of a Hosts entry? The host file has a "read only" attribute. You have to remove it first and then write. FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "-R") --- Write to the file --- When finished set it back to read only FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "+R") This is not the case by default. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ripdad Posted June 12, 2010 Share Posted June 12, 2010 (edited) This is not the case by default.I guess that depends on several factors ... but ..On an XP machine, I've never seen it otherwise - unless someone took it off.btw .. settings in the host file does not take effect until you reboot the pc.This is how the format is with at least 10 spaces between them127.0.0.1 (TENSPACESBETWEEN) localhost127.0.0.1 (TENSPACESBETWEEN) www.mysite.com127.0.0.1 (TENSPACESBETWEEN) www.google.comand so on .......-edit seems edit box was good but the post format changed. i'll fix it. ROFL. Edited June 12, 2010 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 (edited) I guess that depends on several factors ... but ..On an XP machine, I never seen it otherwise - unless someone took it off.mmm .... guess we don't agree here. btw .. settings in the host file does not take effect until you reboot the pc...and I am also not in agreement with this statement. The Host file entries will be in effect directly after the file is saved.Jos Edited June 12, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ripdad Posted June 12, 2010 Share Posted June 12, 2010 (edited) I've never seen it otherwise. again. Anytime I've enabled it, I always had to restart the machine. Of course, that could be because of cache. Anyways .. enough of this .. got to go to bed Edited June 12, 2010 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 I've never seen it otherwise. again.ripdad <--- computer tech 15 yearsNo need to prove you are experienced and am not questioning your findings... but lets at least agree that host file entries are active right after they are saved and that the 10 spaces aren't really needed. Jos <---- 30+ years in IT SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DarkHo Posted June 12, 2010 Author Share Posted June 12, 2010 So ? what code should i have ? Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 So ? what code should i have ?I thought I asked a pretty simple question as reply... so? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ripdad Posted June 12, 2010 Share Posted June 12, 2010 sorry, can't agree. and .. 30 years would put you in the stone age (computer time that is) <grin> "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 (edited) 30 years would put you in the stone age (computer time that is) <grin>Yea we agree on something here ... the computer stone-age was really the punchcard age. Edited June 12, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DarkHo Posted June 12, 2010 Author Share Posted June 12, 2010 Still dont know what to add Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 (edited) Still dont know what to addListen my friend, if memory serves me well: we have been here before.Now what about you start doing some of the thinking, reading and put in some effort yourself? Edited June 12, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DarkHo Posted June 12, 2010 Author Share Posted June 12, 2010 (edited) Like this ? FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "-R") FileWrite("C:\WINDOWS\system32\drivers\etc\hosts", "http://www.mysite.com/blocke/index.html " & GUICtrlRead($url) & @CRLF) MsgBox(64, "Site Added!", GUICtrlRead($url)) FileSetAttrib("C:\WINDOWS\system32\drivers\etc\hosts", "+R") Edited June 12, 2010 by DarkHo Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2010 Developers Share Posted June 12, 2010 Like this ?What are you trying to write to the HOSTS file and how should a Host file record really look? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DarkHo Posted June 12, 2010 Author Share Posted June 12, 2010 What are you trying to write to the HOSTS file and how should a Host file record really look?The host file blockes sites when i enter local ip the site blockes but when i enter a site int dont work Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now