Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Hosts File Tool

  1. #1
    Forum Star
    Join Date
    Jun 2002
    Posts
    1,324
    A small command line tool for adding/removing the supertrick to an existing hosts file.

    Command line:

    hoststool add example.txt

    This will parse the entries in the file example.txt and add them to the hosts file. But only those that are not yet present in the hosts file.

    It should mark the added entries like this:


    (existing entries)

    # BEGIN of Kazaa Lite K++ Supertrick
    (added entries go here)
    # END of Kazaa Lite K++ Supertrick
    If there already is such a block of entries present in the hosts files then it should either insert new entries inside that block, or create a second block. Programmers decision.

    hoststool remove

    This will remove the whole block (or blocks) that where created as shown above.

    Before it does this it should prompt (preferably with a GUI) to ask if the supertrick should really be removed or not. When an extra parameter is used (/s) then it should skip the prompt.

    hoststool removeall

    This will empty the whole hosts file and only add one line:
    127.0.0.1 localhost

  2. File Sharing   -   #2
    How about using a program such as Hostess??? http://accs-net.com/hostess/

  3. File Sharing   -   #3
    Forum Star
    Join Date
    Jun 2002
    Posts
    1,324
    That's too big.

  4. File Sharing   -   #4
    aldo's Avatar Poster
    Join Date
    Jan 2003
    Location
    In front my PC
    Posts
    63
    Try this one:
    http://www.aldostools.com/temp/updatehosts.zip

    If you pass a HOSTS file as command line parameter, it auto-update the current HOSTS file.

    The HOSTS are saved in sorted order.

    ___
    Aldo Vargas
    http://www.aldostools.com

  5. File Sharing   -   #5
    Forum Star
    Join Date
    Jun 2002
    Posts
    1,324
    I will have a look at it. It's better as what I do know with the hosts file.


    I don't think many people will like that it is in sorted order. That way you can't see what was added last.

    Also it has no uninstallation option (yet).

  6. File Sharing   -   #6
    aldo's Avatar Poster
    Join Date
    Jan 2003
    Location
    In front my PC
    Posts
    63
    I have updated the program, now the HOSTS are not sorted. The new additions are listed in the small listbox at the right of the window.

    Also I have fixed a problem with the listbox from Visual Basic 5 when the list contains over 32767 items. Now the Listbox is managed using APIs.

    Download the updated version from the same URL.

    It doesn't require unistallation, due it doesn't write to the registry or install any dll. It only uses standard DLLs from Win32 API.

    ___
    Aldo Vargas
    http://www.aldostools.com

  7. File Sharing   -   #7
    Member
    Join Date
    Feb 2003
    Location
    Vancouver
    Posts
    3
    I think what he means is that there's no option to remove the IP addresses that were added to the Host file. Because he want's the SuperTrick to be able to be "uninstalled" using this tool. It just needs a routine that removes all text between the lines:

    # BEGIN of Kazaa Lite K++ Supertrick

    # END of Kazaa Lite K++ Supertrick

    or whatever you've made it.

  8. File Sharing   -   #8
    Barbarossa's Avatar mostly harmless
    Join Date
    Jun 2002
    Location
    Over here!
    Posts
    15,180
    Hosts file update tools are a pain, because MicroShaft decided to change the location of the hosts file in different releases of Windows.

    In 95, 98, ME it's in "C:\Windows\"

    In XP, it's in "C:\Windows\system32\drivers\etc\"

    I dunno where it is on NT or 2000.. Anyway, I'm sure Aldo has taken all this into account

  9. File Sharing   -   #9
    Livy's Avatar Simpleton
    Join Date
    Mar 2003
    Location
    Scotland
    Posts
    3,013
    in nt and 2000 its in the same place as xp, or the proper way would be in xp its in the same place as 2000, but this is the same for other things aswell, as they are different os's for diff things,

  10. File Sharing   -   #10
    Poster
    Join Date
    Jan 2003
    Location
    United Kingdom
    Posts
    1,184
    I can do this, I did a similar thing with XML and importing/exporting them into TEXT files.

    Easy, here's what'd it look like in C++:

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    
    int main()
    
    {
    
     string supertrick;
    
     ifstream example("example.txt");
     if ( ! example )
      {
       cout << "Error opening example file." << endl;
       return -1;
      }
    
     ofstream hosts("hosts.txt", ios::app);
     if ( ! hosts )
      {
       cout << "Error opening example file." << endl;
       return -1;
      }
    
     while ( ! example.eof() )
      {
       getline(example, supertrick);
       hosts << example << endl;
    
      }
    
     hosts.close();
     example.close();
    
     return 0;
    
    }
    I think I uninstalled the GNU C++ Compiler, so someone will have to test this application out and debug it.

    In the Command Prompt use the following line to compile:

    C++ example.cpp -o example.exe
    And then simply run:
    example.exe
    All in red, obviously needs to be changed accordingly.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •