Jump to content

Creating a bat file


LonePirate

Recommended Posts

I want to create a bat file with all of google's domains added to my hostsfile but not sure how to do it?
I found one online, but it doesn't work on my w7 x64 laptop???

here's the bat file in question

Link to comment
Share on other sites


  • Replies 10
  • Views 926
  • Created
  • Last Reply

Here is a simple solution for u:

 

ATTRIB -r %WINDIR%\system32\drivers\etc\hosts
@ECHO OFF
IF "%OS%"=="Windows_NT" (
SET HOSTFILE=%windir%\system32\drivers\etc\hosts
) ELSE (
SET HOSTFILE=%windir%\hosts
)
FIND /C /I "the adress u want to block" %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1       again the adress u want to block>>%WINDIR%\system32\drivers\etc\hosts

 

ATTRIB +r %WINDIR%\system32\drivers\etc\hosts
IPCONFIG -flushdns
CLS
PAUSE

 

Link to comment
Share on other sites


21 minutes ago, LonePirate said:

Can you tell me if the bat file I posted works? I need it to re-direct to google safe search for parental control reasons

 

safesearch hosts.bat

Works fine

 

you might want to consider backuping up the original, and unhiding (a lot of people make their hosts file read-only and hidden for security) and rehiding it after processing

 

From my setupcomplete.cmd file i use in deployment (i backup the original hosts and replace it with my custom one with a lot of telemetry blocking)

 

 

Quote

start /wait cmd /c copy %WinDir%\System32\drivers\etc\hosts %WinDir%\System32\drivers\etc\hosts.orig
start /wait cmd /c attrib -r -h %WinDir%\System32\drivers\etc\hosts
start /wait cmd /c copy "%CDROM%\extra\hosts"  %WinDir%\System32\drivers\etc\
start /wait cmd /c attrib +r +h %WinDir%\System32\drivers\etc\hosts

 

You might wish to use:


 

Quote

 

start /wait cmd /c copy %WinDir%\System32\drivers\etc\hosts %WinDir%\System32\drivers\etc\hosts.orig
start /wait cmd /c attrib -r -h %WinDir%\System32\drivers\etc\hosts

 

 

 

 

at the beginning of your batch

 

and

 

Quote

start /wait cmd /c attrib +r +h %WinDir%\System32\drivers\etc\hosts

 

at the end

Link to comment
Share on other sites


11 minutes ago, stylemessiah said:

Works fine

 

you might want to consider backuping up the original, and unhiding (a lot of people make their hosts file read-only and hidden for security) and rehiding it after processing

 

From my setupcomplete.cmd file i use in deployment (i backup the original hosts and replace it with my custom one with a lot of telemetry blocking)

 

 

 

You might wish to use:


 

 

at the beginning of your batch

 

and

 

 

at the end

Why wouldn't it work on my laptop? I ran it as admin but my hosts wasn't changed. Could you possibly copy the hosts entries that the bat created and share it?

Link to comment
Share on other sites


24 minutes ago, LonePirate said:

Why wouldn't it work on my laptop? I ran it as admin but my hosts wasn't changed. Could you possibly copy the hosts entries that the bat created and share it?

Your hosts file may be hidden and read-only, that would stop it creating the entries, which is why i suggested what i did above....

 

Quote

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host
# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost

#forcesafesearch
216.239.38.120 www.google.com
216.239.38.120 www.google.ad
216.239.38.120 www.google.ae
216.239.38.120 www.google.com.af
216.239.38.120 www.google.com.ag
216.239.38.120 www.google.com.ai
216.239.38.120 www.google.al
216.239.38.120 www.google.am
216.239.38.120 www.google.co.ao
216.239.38.120 www.google.com.ar
216.239.38.120 www.google.as
216.239.38.120 www.google.at
216.239.38.120 www.google.com.au
216.239.38.120 www.google.az
216.239.38.120 www.google.ba
216.239.38.120 www.google.com.bd
216.239.38.120 www.google.be
216.239.38.120 www.google.bf
216.239.38.120 www.google.bg
216.239.38.120 www.google.com.bh
216.239.38.120 www.google.bi
216.239.38.120 www.google.bj
216.239.38.120 www.google.com.bn
216.239.38.120 www.google.com.bo
216.239.38.120 www.google.com.br
216.239.38.120 www.google.bs
216.239.38.120 www.google.bt
216.239.38.120 www.google.co.bw
216.239.38.120 www.google.by
216.239.38.120 www.google.com.bz
216.239.38.120 www.google.ca
216.239.38.120 www.google.cd
216.239.38.120 www.google.cf
216.239.38.120 www.google.cg
216.239.38.120 www.google.ch
216.239.38.120 www.google.ci
216.239.38.120 www.google.co.ck
216.239.38.120 www.google.cl
216.239.38.120 www.google.cm
216.239.38.120 www.google.cn
216.239.38.120 www.google.com.co
216.239.38.120 www.google.co.cr
216.239.38.120 www.google.com.cu
216.239.38.120 www.google.cv
216.239.38.120 www.google.com.cy
216.239.38.120 www.google.cz
216.239.38.120 www.google.de
216.239.38.120 www.google.dj
216.239.38.120 www.google.dk
216.239.38.120 www.google.dm
216.239.38.120 www.google.com.do
216.239.38.120 www.google.dz
216.239.38.120 www.google.com.ec
216.239.38.120 www.google.ee
216.239.38.120 www.google.com.eg
216.239.38.120 www.google.es
216.239.38.120 www.google.com.et
216.239.38.120 www.google.fi
216.239.38.120 www.google.com.fj
216.239.38.120 www.google.fm
216.239.38.120 www.google.fr
216.239.38.120 www.google.ga
216.239.38.120 www.google.ge
216.239.38.120 www.google.gg
216.239.38.120 www.google.com.gh
216.239.38.120 www.google.com.gi
216.239.38.120 www.google.gl
216.239.38.120 www.google.gm
216.239.38.120 www.google.gp
216.239.38.120 www.google.gr
216.239.38.120 www.google.com.gt
216.239.38.120 www.google.gy
216.239.38.120 www.google.com.hk
216.239.38.120 www.google.hn
216.239.38.120 www.google.hr
216.239.38.120 www.google.ht
216.239.38.120 www.google.hu
216.239.38.120 www.google.co.id
216.239.38.120 www.google.ie
216.239.38.120 www.google.co.il
216.239.38.120 www.google.im
216.239.38.120 www.google.co.in
216.239.38.120 www.google.iq
216.239.38.120 www.google.is
216.239.38.120 www.google.it
216.239.38.120 www.google.je
216.239.38.120 www.google.com.jm
216.239.38.120 www.google.jo
216.239.38.120 www.google.co.jp
216.239.38.120 www.google.co.ke
216.239.38.120 www.google.com.kh
216.239.38.120 www.google.ki
216.239.38.120 www.google.kg
216.239.38.120 www.google.co.kr
216.239.38.120 www.google.com.kw
216.239.38.120 www.google.kz
216.239.38.120 www.google.la
216.239.38.120 www.google.com.lb
216.239.38.120 www.google.li
216.239.38.120 www.google.lk
216.239.38.120 www.google.co.ls
216.239.38.120 www.google.lt
216.239.38.120 www.google.lu
216.239.38.120 www.google.lv
216.239.38.120 www.google.com.ly
216.239.38.120 www.google.co.ma
216.239.38.120 www.google.md
216.239.38.120 www.google.me
216.239.38.120 www.google.mg
216.239.38.120 www.google.mk
216.239.38.120 www.google.ml
216.239.38.120 www.google.com.mm
216.239.38.120 www.google.mn
216.239.38.120 www.google.ms
216.239.38.120 www.google.com.mt
216.239.38.120 www.google.mu
216.239.38.120 www.google.mv
216.239.38.120 www.google.mw
216.239.38.120 www.google.com.mx
216.239.38.120 www.google.com.my
216.239.38.120 www.google.co.mz
216.239.38.120 www.google.com.na
216.239.38.120 www.google.com.nf
216.239.38.120 www.google.com.ng
216.239.38.120 www.google.com.ni
216.239.38.120 www.google.ne
216.239.38.120 www.google.nl
216.239.38.120 www.google.no
216.239.38.120 www.google.com.np
216.239.38.120 www.google.nr
216.239.38.120 www.google.nu
216.239.38.120 www.google.co.nz
216.239.38.120 www.google.com.om
216.239.38.120 www.google.com.pa
216.239.38.120 www.google.com.pe
216.239.38.120 www.google.com.pg
216.239.38.120 www.google.com.ph
216.239.38.120 www.google.com.pk
216.239.38.120 www.google.pl
216.239.38.120 www.google.pn
216.239.38.120 www.google.com.pr
216.239.38.120 www.google.ps
216.239.38.120 www.google.pt
216.239.38.120 www.google.com.py
216.239.38.120 www.google.com.qa
216.239.38.120 www.google.ro
216.239.38.120 www.google.ru
216.239.38.120 www.google.rw
216.239.38.120 www.google.com.sa
216.239.38.120 www.google.com.sb
216.239.38.120 www.google.sc
216.239.38.120 www.google.se
216.239.38.120 www.google.com.sg
216.239.38.120 www.google.sh
216.239.38.120 www.google.si
216.239.38.120 www.google.sk
216.239.38.120 www.google.com.sl
216.239.38.120 www.google.sn
216.239.38.120 www.google.so
216.239.38.120 www.google.sm
216.239.38.120 www.google.sr
216.239.38.120 www.google.st
216.239.38.120 www.google.com.sv
216.239.38.120 www.google.td
216.239.38.120 www.google.tg
216.239.38.120 www.google.co.th
216.239.38.120 www.google.com.tj
216.239.38.120 www.google.tk
216.239.38.120 www.google.tl
216.239.38.120 www.google.tm
216.239.38.120 www.google.tn
216.239.38.120 www.google.to
216.239.38.120 www.google.com.tr
216.239.38.120 www.google.tt
216.239.38.120 www.google.com.tw
216.239.38.120 www.google.co.tz
216.239.38.120 www.google.com.ua
216.239.38.120 www.google.co.ug
216.239.38.120 www.google.co.uk
216.239.38.120 www.google.com.uy
216.239.38.120 www.google.co.uz
216.239.38.120 www.google.com.vc
216.239.38.120 www.google.co.ve
216.239.38.120 www.google.vg
216.239.38.120 www.google.co.vi
216.239.38.120 www.google.com.vn
216.239.38.120 www.google.vu
216.239.38.120 www.google.ws
216.239.38.120 www.google.rs
216.239.38.120 www.google.co.za
216.239.38.120 www.google.co.zm
216.239.38.120 www.google.co.zw
216.239.38.120 www.google.cat
#end of forcesafesearch

 

 

Link to comment
Share on other sites


I'll have to dive deeper to see what's going on, I have no problem updating my hosts with hostsman so not sure why the bat file didn't work :unsure:

I appreciate your help

Link to comment
Share on other sites


knowledge-Spammer
1 hour ago, LonePirate said:

I'll have to dive deeper to see what's going on, I have no problem updating my hosts with hostsman so not sure why the bat file didn't work :unsure:

I appreciate your help

try and close hostsman  and then run bat

Link to comment
Share on other sites


knowledge-Spammer
39 minutes ago, LonePirate said:

Hostsman isn't running on startup

with hostman try like this
tools
open host folder then use in command prompt
and copy and pasta

AiSn701.jpg

seems fine for me

but if u ad them  sites  google will not search 100% just so u no

yV47H9D.jpg

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...