MrVietA2 Posted September 21, 2011 Posted September 21, 2011 Hi everyone !I have a 1 question : " How can I open hosts file in windows with autoit code ? ". I tried by some other program but failed ! Help me plz ! Thank you !
JScript Posted September 21, 2011 Posted September 21, 2011 Hi, try this: João Carlos. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 Hi, try this: João Carlos. I include the au3 file and use _HostRead("C:\Windows\System32\drivers\etc\hosts") but it doesn't work . Help me, thanks
JScript Posted September 22, 2011 Posted September 22, 2011 You must to be use this directive: #RequireAdminCompile your script and see the result!João Carlos. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 (edited) You must to be use this directive: #RequireAdminCompile your script and see the result! João Carlos. I try but it doesn't work, can you help me on Yahoo ?Y!M : destinystars_neverstop@yahoo.comThanks ! Edited September 22, 2011 by MrVietA2
JScript Posted September 22, 2011 Posted September 22, 2011 Doubts only here, and the UDF was only tested on XP! João Carlos. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 (edited) Doubts only here, and the UDF was only tested on XP! João Carlos. My OS is windows 7 , what else ? How can I do that ? Edited September 22, 2011 by MrVietA2
JScript Posted September 22, 2011 Posted September 22, 2011 (edited) My OS is Win7 and it works perfectly! #RequireAdmin _HostWrite("127.0.0.0", "Computer", 1) $asHost = _HostRead() _ArrayDisplay($asHost, "HostFile") _HostDelete("127.0.0.0", "Computer") $asHost = _HostRead() _ArrayDisplay($asHost, "HostFile") João Carlos. Edited September 22, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 That is use like a box, but i want to compile my script , run and like this :
JScript Posted September 22, 2011 Posted September 22, 2011 (edited) Inside the source of the UDF, you will see these lines:; ; Skip comment lines proceeded by: # If StringLen($Line) < 10 Or StringRegExp(StringStripWS($Line, 8), "\A#") Then ContinueLoop ;Your hosts file only have comments? João Carlos. Edited September 22, 2011 by jscript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 Inside the source of the UDF, you will see these lines:; ; Skip comment lines proceeded by: # If StringLen($Line) < 10 Or StringRegExp(StringStripWS($Line, 8), "\A#") Then ContinueLoop ;Your hosts file only have comments? João Carlos. I don't understand , i want to open hosts file with notepad like #9, can you help me ? Thanks
JScript Posted September 22, 2011 Posted September 22, 2011 Simple:ShellExecute(@SystemDir & "\Notepad.exe", @SystemDir & "\Drivers\Etc\hosts", "") João Carlos. MrVietA2 1 http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 Simple:ShellExecute(@SystemDir & "\Notepad.exe", @SystemDir & "\Drivers\Etc\hosts", "") João Carlos. Oh, it work ! Thanks ! Can use : #include <Process.au3> _RunDOS("start %windir%\notepad.exe %windir%\system32\drivers\etc\hosts")
JScript Posted September 22, 2011 Posted September 22, 2011 But open a command prompt for that! João Carlos. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!
BrewManNH Posted September 22, 2011 Posted September 22, 2011 Why would you use _RunDOS over Run or ShellExectute? No includes needed with either of the others, and _RunDOS should only be used for things that won't work any other way. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 (edited) I have an other question : " How can I make a hosts file with FileOpen() ? " . Thanks so much Edited September 22, 2011 by MrVietA2
Bert Posted September 22, 2011 Posted September 22, 2011 Why are you so intent on editing your host file with an AutoIt script? No, we won't give you "personal" service with instant messenger. You need to post your code and explain what you have in mind. Saying "I want to open my HOST file isn't enough. WHY you want to do it and the purpose of doing it would explain much. MrVietA2 1 The Vollatran project My blog: http://www.vollysinterestingshit.com/
GEOSoft Posted September 22, 2011 Posted September 22, 2011 One of my very first released AutoIt Scripts was a HOST file manager, so yes; there are legitimate reasons for working with the host file. @MrVietA2 You use FileOpen(), File Read(), FileClose() the same way for Host as you do for any other file and all the help required for that is in the Help file. For simply reading it you don't need FileOpen() at all; just go with FileRead(). There are also not so legit reasons for messing with that file and if you get caught doing any of those it won't be a nice outcome. Understandably people are suspicious when you start playing with certain files. Of course the easiest way for people to avoid problems with HOST is to keep it regularly updated and have a look at the checksum periodically. MrVietA2 1 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!"
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 (edited) Why are you so intent on editing your host file with an AutoIt script? No, we won't give you "personal" service with instant messenger. You need to post your code and explain what you have in mind. Saying "I want to open my HOST file isn't enough. WHY you want to do it and the purpose of doing it would explain much. I only want to open hosts file and want user can edit it , nothing else ! This is my code : #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Open hosts file !", 316, 130, 407, 229) $Label1 = GUICtrlCreateLabel("OPEN THE HOSTS FILE IN WINDOWS", 16, 24, 285, 23) GUICtrlSetFont(-1, 12, 800, 0, "Times New Roman") GUICtrlSetColor(-1, 0x008000) $Button1 = GUICtrlCreateButton("OPEN", 80, 56, 153, 57) GUICtrlSetFont(-1, 11, 800, 0, "Times New Roman") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _open() EndSwitch WEnd Func _open() ShellExecute(@SystemDir & "\Notepad.exe", @SystemDir & "\Drivers\Etc\hosts", "") EndFunc @GEOsoft : I know how to do this , thanks for that THANKS ALL Edited September 22, 2011 by MrVietA2
MrVietA2 Posted September 22, 2011 Author Posted September 22, 2011 (edited) I compile my script to exe file but it can decompile . I have 1 question : " How can I protect my source not decompile ? ". Thanks P/s : My English is bad, sorry about that Edited September 22, 2011 by MrVietA2
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