Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How can i add text to a host file through cmd?  (Read 17844 times)

0 Members and 1 Guest are viewing this topic.

shrshr429

    Topic Starter


    Beginner

    How can i add text to a host file through cmd?
    « on: July 03, 2009, 06:47:02 PM »
    I just want to add (example):


    127.0.0.1 localhost
    127.0.0.1 google.com

    to my host file - windows\sytem32\drivers\etc\hosts

    through cmd, how can i do this?

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: How can i add text to a host file through cmd?
    « Reply #1 on: July 03, 2009, 07:56:36 PM »
    Why thru .cmd  ? ?
    Open it in Notepad and add the revisions.
    " Anyone who goes to a psychiatrist should have his head examined. "

    fat_basterd21



      Apprentice

      Thanked: 15
    • Experience: Experienced
    • OS: Windows Vista
    Re: How can i add text to a host file through cmd?
    « Reply #2 on: July 03, 2009, 08:48:12 PM »
    take a look here
    http://technet.microsoft.com/en-us/library/bb490982.aspx

    >> is the append command so the output will always be written to the end of the file rather than overwriting. Just using > will overwrite the file each time.

    syntax is "(command) >> windows\sytem32\drivers\etc\hosts.txt"

    Or
    "echo 127.0.0.1 localhost >> windows\sytem32\drivers\etc\hosts.txt"
    "echo 127.0.0.1 google.com >> windows\sytem32\drivers\etc\hosts.txt"
    CAPS LOCK IS CRUISE-CONTROL FOR COOL!!!

    Broni


      Mastermind
    • Kraków my love :)
    • Thanked: 614
      • Computer Help Forum
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 8
    Re: How can i add text to a host file through cmd?
    « Reply #3 on: July 03, 2009, 09:18:57 PM »
    Quote
    Why thru .cmd  ? ?
    Open it in Notepad and add the revisions.

    shrshr429

      Topic Starter


      Beginner

      Re: How can i add text to a host file through cmd?
      « Reply #4 on: July 03, 2009, 10:40:10 PM »
      I want to make it into a batch file and autorun on a cd, its going to block known spyware websites.

      Broni


        Mastermind
      • Kraków my love :)
      • Thanked: 614
        • Computer Help Forum
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 8
      Re: How can i add text to a host file through cmd?
      « Reply #5 on: July 03, 2009, 10:43:18 PM »
      Honestly, I have no idea what you're trying to do. Why on CD? Hosts file must be located in certain folder, not on CD.

      shrshr429

        Topic Starter


        Beginner

        Re: How can i add text to a host file through cmd?
        « Reply #6 on: July 03, 2009, 10:59:34 PM »
        Make a batch file that adds


        # Start of entries inserted by Spybot - Search & Destroy
        127.0.0.1 www.007guard.com
        127.0.0.1 007guard.com
        127.0.0.1 008i.com
        127.0.0.1 www.008k.com
        127.0.0.1 008k.com
        127.0.0.1 www.00hq.com
        127.0.0.1 00hq.com
        127.0.0.1 010402.com
        127.0.0.1 www.032439.com
        127.0.0.1 032439.com
        127.0.0.1 www.0scan.com
        127.0.0.1 0scan.com
        127.0.0.1 www.1000gratisproben.com
        127.0.0.1 1000gratisproben.com
        127.0.0.1 www.1001namen.com
        127.0.0.1 1001namen.com
        127.0.0.1 100888290cs.com
        127.0.0.1 www.100888290cs.com

        to the host file located in Windows\system32\drivers\etc\host

        make that autorun on a cd.

        Broni


          Mastermind
        • Kraków my love :)
        • Thanked: 614
          • Computer Help Forum
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 8
        Re: How can i add text to a host file through cmd?
        « Reply #7 on: July 03, 2009, 11:09:29 PM »
        Why does it have to run from some CD, not to go straight to Windows\system32\drivers\etc\?

        fat_basterd21



          Apprentice

          Thanked: 15
        • Experience: Experienced
        • OS: Windows Vista
        Re: How can i add text to a host file through cmd?
        « Reply #8 on: July 03, 2009, 11:59:44 PM »
        Or why not make a .txt file and just save/copy it from a disk?
        CAPS LOCK IS CRUISE-CONTROL FOR COOL!!!

        shrshr429

          Topic Starter


          Beginner

          Re: How can i add text to a host file through cmd?
          « Reply #9 on: July 04, 2009, 12:18:26 AM »
          ok then lets look at this differently, if i had a file (hosts) on the cd, how can i replace that tifle with the host file on the computer through cmd. The reason i want to do it through cmd is so i can make a batch file so it can autorun right off the cd.

          soybean



            Genius
          • The first soybean ever to learn the computer.
          • Thanked: 469
          • Computer: Specs
          • Experience: Experienced
          • OS: Windows 10
          Re: How can i add text to a host file through cmd?
          « Reply #10 on: July 04, 2009, 07:24:23 AM »
          ok then lets look at this differently, if i had a file (hosts) on the cd, how can i replace that tifle with the host file on the computer through cmd. The reason i want to do it through cmd is so i can make a batch file so it can autorun right off the cd.
          Your obsession with this technique seems quite odd.  Is this just for your computer, or do you intend this CD to be used for many computers? 

          shrshr429

            Topic Starter


            Beginner

            Re: How can i add text to a host file through cmd?
            « Reply #11 on: July 04, 2009, 02:57:38 PM »
            Other computers.

            shrshr429

              Topic Starter


              Beginner

              Re: How can i add text to a host file through cmd?
              « Reply #12 on: July 04, 2009, 05:27:24 PM »
              Lets change the question since this is confusing. I know how to delete a file through cmd, so if i delete the host file through cmd, what would be the script to move a file from a cd to the host file's location.
              « Last Edit: July 04, 2009, 09:02:16 PM by shrshr429 »

              fat_basterd21



                Apprentice

                Thanked: 15
              • Experience: Experienced
              • OS: Windows Vista
              Re: How can i add text to a host file through cmd?
              « Reply #13 on: July 04, 2009, 09:14:12 PM »
              copy
              CAPS LOCK IS CRUISE-CONTROL FOR COOL!!!