Changing DNS With A .bat File

JakeC112

New member
Local time
1:00 PM
Messages
3
Hi,

I am doing exams soon so I need to start studying. I have set up OpenDNS to block some websites that may distract me but I don't need them blocked all the time. As OpenDNS offers no settings for time to block I need to change the DNS server back to my ISP's when the blocking is not needed. The command to change DNS in Command Prompt is

"C:\Netsh Interface ip set dns "Local Area Connection" static "[DNS GOES HERE]"

But with a START command in front of it this command does not work when put into a batch program:mad:.

Does anyone know either a better way of changing the DNS at different times or the correct way to insert this command into a batch file.

Thanks
Jake
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell
OS
Windows 7 Professional x64
CPU
Intel i5 2470
Memory
8GB DDR3
Graphics Card(s)
INtel HD Graphics
Monitor(s) Displays
1: DELL SE197FP 2: COMPAQ FP5315
Antivirus
McAfee Security Center
Browser
Google Chrome
This may not be exactly what you want but you could always use your host file to redirect or simply block websites that may distract you.

http://www.sevenforums.com/tutorials/78266-hosts-file-use-windows-7-vista.html

Simply follow this tutorial. You don't have to use 127.0.0.1, which is your loopback address. You can use the IP address of say, a website you should be studying instead of your distractions :)

Simply erase the entries from the blocked files when you don't want them blocked.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom
OS
Dual Boot: Windows 8.1 & Server 2012r2 VMs: Kali Linux, Backbox, Matriux, Windows 8.1
CPU
A10 7700 Kavari SteamRoller
Motherboard
ASUS A88XM-PLUS (FM2+ )
Memory
8GB DDR3 SDRAM PC3-8500
Graphics Card(s)
1024MB ATI AMD Radeon R7 Graphics
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
Samsung
Hard Drives
SSD Crucial 120gb
WD VelociRaptor 1tb
PSU
Rosewill Gaming 650w
Case
Rosewill Galaxy 2
Internet Speed
55/12
Antivirus
Malwarebytes, MSE, SAS
Browser
FireFox, Chrome
Hi,

You change it by modifying your Registry files. It works like a charm for me.
(Make it .bat and start it)
Code:
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "SearchList" /t REG_SZ /d "YOUR DNS"
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "NV Domain" /t REG_SZ /d "YOUR DNS"
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "Domain" /t REG_SZ /d "YOUR DNS"
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "DhcpDomain" /t REG_SZ /d "YOUR DNS"
This will clear it up the record from the registry.
Code:
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "SearchList" /t REG_SZ /d "" 
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "NV Domain" /t REG_SZ /d "" 
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "Domain" /t REG_SZ /d "" 
reg add "HKLM\System\CurrentControlSet\services\tcpip\Parameters" /f /v "DhcpDomain" /t REG_SZ /d ""

Good luck with you studying
F.
 

My Computer

Computer type
PC/Desktop
OS
Win 7 Enterprise x64
~~~
But with a START command in front of it this command does not work when put into a batch program:mad:.
~~~

Don't use START.

Try this:
Code:
netsh interface ipv4 set dns name="Local Area Connection" static 8.8.8.8 primary
netsh interface ipv4 add dns name="Local Area Connection" 8.8.4.4
ipconfig /flushdns
pause
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Employer provided Dell Latitude
OS
W7 Pro SP1 64bit
CPU
i7
Memory
8GB
Graphics Card(s)
Intel HD Graphics
Hard Drives
crappy SSD
Antivirus
Employer mandated Symantec Endpoint Protection
Browser
Pale Moon 64bit, IE11 64bit & Chrome 64bit
Back
Top