IP address modification batch processing program

Source: Internet
Author: User
Tags dns2 netconf

[Nature] batch processing program
[PURPOSE] facilitates switching between multiple IP addresses
[Applicable] A little bit of BAT, like small and command line, usually need to switch IP
[Author] lile
[Homepage] not available yet. Haha, come here for updates (if you need updates)
[Document] There is no need to use tools to quickly switch IP addresses
[Tip] advanced users can modify the content accordingly, which simplifies a lot of content. The command line supports parameters, so I am used to "ip BJ" ip 0 "instead of selecting the menu after entering.

The source code is as follows (save it as easyip. BAT)
--------------------------------------------------------------------------------

: Last updated 20070405, xbeta released, author lile
@ Echo off
Title easyip v1.3
:::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::
: Easyip v1.3
: Author: lile
:::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::

:::::::: ::::::::::::::::::::::::::
@ REM menu content settings: ========================================================== ======================
Set menu1 = oil server (COSL)
Set menu2 = Head Office 1004
Set menu3 = Western company
Set menu4 = sun)
Set menu5 = standby
Set menu6 = standby
 
@ REM sets the proxy server address to be used ================================ ================
Set proxyservervalue = 10.68.200.233: 8080
@ REM no need to use the address of the proxy server. Note: ", <local>" indicates the address that is not needed to be activated and must be retained.
Set proxyoverridevalue = "10. *, <local>"

@ REM here, set the information of the 1st IP addresses ==================================== ==============================
Set myip1 = 10.56.100.143
Set mygateway1 = 10.56.100.254
Set mymask1 = 255.255.255.0
Set dns11 = 10.68.100.211
Set dns21 = 10.68.100.212

@ REM here, set the information of the 2nd IP addresses ==================================== ==============================
Set myip2 = 10.68.68.85
Set mygateway2 = 10.68.68.254
Set mymask2 = 255.255.255.0
Set dns12 = 10.68.100.211
Set dns22 = 10.68.100.212

@ REM here, set the information of the 3rd IP addresses ==================================== ==============================
Set myip3 = 10.170.97.72
Set mygateway3 = 10.170.97.254
Set mymask3 = 255.255.255.0
Set dns13 = 85.20.116.56
Set dns23 = 85.20.112.146

@ REM here, set the information of the 4th IP addresses ==================================== ==============================
Set myip4 = 192.168.0.199
Set mygateway4 = 192.168.0.125
Set mymask4 = 255.255.255.0
Set dns14 = 211.147.6.3
Set dns24 = 202.98.96.68

@ REM here, set the information of the 5th IP addresses ==================================== ==============================
Set myip5 =
Set mygateway5 =
Set mymask5 =
Set dns15 =
Set dns25 =
 
@ REM here, set the information of the 6th IP addresses ==================================== ==============================
Set myip6 =
Set mygateway6 =
Set mymask6 =
Set dns16 =
Set dns26 =

@ REM set the name of the network connection to be changed ================================== ====================
: If exist "% allusersprofile %"/desktop/set netconf = "Local Area Connection"
: If exist "% allusersprofile %"/desktop/set netconf = "Local Connection"
Set netconf = "local"
 
@ REM set the IP address to be tested ====================================== ============================
Set testip = "10.68.68.254"
:::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::

If "% 1%" = "1" Goto ip_1
If "% 1%" = "BJ" Goto ip_2
If "% 1%" = "3" Goto IP_3
If "% 1%" = "4" Goto ip_4
If "% 1%" = "5" Goto ip_5
If "% 1%" = "6" Goto ip_6
If "% 1%" = "H" Goto ip_h_nomenu
If "% 1%" = "H" Goto ip_h_nomenu
If "% 1%" = "S" Goto ip_s
If "% 1%" = "S" Goto ip_s
If & quot; % 1% & quot; = & quot; P & quot; goto ip_p & quot;
If & quot; % 1% & quot; = & quot; P & quot; goto ip_p & quot;
If "% 1%" = "N" Goto ip_n
If "% 1%" = "N" Goto ip_n
If "% 1%" = "T" Goto ip_t_nomenu
If "% 1%" = "T" Goto ip_t_nomenu
If "% 1%" = "0" Goto ip_0

Goto menu

@ REM ===================================================== ==========================================================
: Menu
Echo.
Echo.
Echo easyip v1.3
Echo.
Echo ========================================
Echo 1: % menu1 %
Echo 2: % menu2 %
Echo 3: % menu3 %
Echo 4: % menu4 %
Echo 5: % menu5 %
Echo 6: % menu6 %
Echo ----------------------------
Echo P: use IE Proxy Server
Echo N: Do not use the IE Proxy Server
Echo ----------------------------
Echo H: Help
Echo S: settings
Echo T: Test Network
Echo 0: automatically obtain the IP address
Echo ----------------------------
Echo Q: Exit
Echo ========================================

Set/P input = enter the selected code [eg: 1, h...]:
If "% input %" = "0" Goto ip_0
If "% input %" = "1" Goto ip_1
If "% input %" = "2" Goto ip_2
If "% input %" = "3" Goto IP_3
If "% input %" = "4" Goto ip_4
If "% input %" = "5" Goto ip_5
If "% input %" = "6" Goto ip_6
If "% input %" = "H" Goto ip_h
If "% input %" = "H" Goto ip_h
If "% input %" = "S" Goto ip_s
If "% input %" = "S" Goto ip_s
If "% input %" = "p" Goto ip_p
If "% input %" = "p" Goto ip_p
If "% input %" = "N" Goto ip_n
If "% input %" = "N" Goto ip_n
If "% input %" = "T" Goto ip_t
If "% input %" = "T" Goto ip_t
If "% input %" = "Q" Exit
If "% input %" = "Q" Exit
CLS
Goto menu

@ REM ===================================================== ==========================================================
: Ip_1
Set myip = % myip1 %
Set mygateway = % mygateway1 %
Set mymask = % mymask1 %
Set dns1 = % dns11 %
Set dns2 = % dns21 %
Goto end

@ REM ===================================================== ==========================================================
: Ip_2
Set myip = % myip2 %
Set mygateway = % mygateway2 %
Set mymask = % mymask2 %
Set dns1 = % dns12 %
Set dns2 = % dns22 %
Goto end

@ REM ===================================================== ==========================================================
: IP_3
Set myip = % myip3 %
Set mygateway = % mygateway3 %
Set mymask = % mymask3 %
Set dns1 = % dns13 %
Set dns2 = % dns23 %
Goto end

@ REM ===================================================== ==========================================================
: Ip_4
Set myip = % myip4 %
Set mygateway = % mygateway4 %
Set mymask = % mymask4 %
Set dns1 = % dns14 %
Set dns2 = % dns24 %
Goto end

@ REM ===================================================== ==========================================================
: Ip_5
Set myip = % myip5 %
Set mygateway = % mygateway5 %
Set mymask = % mymask5 %
Set dns1 = % dns15 %
Set dns2 = % dns25 %
Goto end

@ REM ===================================================== ==========================================================
: Ip_6
Set myip = % myip6 %
Set mygateway = % mygateway6 %
Set mymask = % mymask6 %
Set dns1 = % dns16 %
Set dns2 = % dns26 %
Goto end

@ REM ===================================================== ==========================================================
: Ip_h
CLS
Echo ::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::
Echo easyip v1.3
Echo Author: lile
Echo.
Echo instructions:
ECHO has many IP address modification tools on the Internet, but it is inconvenient to install them or install several files.
Echo compiled the program based on actual needs, and only a few K of batch processing can be used to complete daily needs.
Echo.
Echo modification instructions:
Echo uses any text editor, or right-click it and select "edit.
Echo in "system settings", set the content to be modified according to the notes.
Echo currently provides ipsettings, proxy server settings, network testing, and other functions.
ECHO can be adjusted as needed.
Echo.
Echo upgrade history:
Echo v1.3 is greatly changed. All parameters can be modified as variables. Currently, the most comprehensive and stable version is available.
Echo V1.1 modified the registry modification method, and added support for command line parameters.
The echo V1.0 program is basically completed, implementing the most basic IP fast switching function
Echo.
Echo ::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::
Pause
CLS
Goto menu

@ REM ===================================================== ==========================================================
: Ip_h_nomenu
CLS
Echo ::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::
Echo easyip v1.3
Echo Author: lile
Echo.
Echo instructions:
ECHO has many IP address modification tools on the Internet, but it is inconvenient to install them or install several files.
Echo compiled the program based on actual needs, and only a few K of batch processing can be used to complete daily needs.
Echo.
Echo modification instructions:
Echo uses any text editor, or right-click it and select "edit.
Echo in "system settings", set the content to be modified according to the notes.
Echo currently provides ipsettings, proxy server settings, network testing, and other functions.
ECHO can be adjusted as needed.
Echo.
Echo upgrade history:
Echo v1.3 is greatly changed. All parameters can be modified as variables.
Echo V1.1 modified the Registry Modification Method and added support for command line parameters;
The echo V1.0 program is basically completed, implementing the most basic IP fast switching function
Echo.
Echo ::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::
Pause
Exit

@ REM ===================================================== ==========================================================
: Ip_s
@ REM settings
CLS
Echo ::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::
Echo easyip v1.3
Echo Author: lile
Echo.
Echo settings:
Echo.
Right-click echo and select "edit" or use any text editor to edit the program,
All echo parameters can be modified according to the instructions in "system settings.
Echo currently provides the following command line parameters:
Echo 1-6: Call the 1-6 IP settings
Echo P: use IE Proxy Server
Echo N: Do not use the IE Proxy Server
Echo H: Call help documentation
Echo S: Call setting instructions
Echo T: ping the specified IP Address
Echo.
Echo ::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::
Pause
CLS
Goto menu

@ REM ===================================================== ==========================================================
: Ip_p
Reg Add "HKEY_CURRENT_USER/software/Microsoft/Windows/CurrentVersion/Internet Settings"/V proxyserver/T REG_SZ/d % proxyservervalue %/F
Reg Add "HKEY_CURRENT_USER/software/Microsoft/Windows/CurrentVersion/Internet Settings"/V proxyoverride/T REG_SZ/d % proxyoverridevalue %/F
Reg Add "HKEY_CURRENT_USER/software/Microsoft/Windows/CurrentVersion/Internet Settings"/V proxyenable/T REG_DWORD/d 00000001/F
Exit

@ REM ===================================================== ==========================================================
: Ip_n
Reg Add "HKEY_CURRENT_USER/software/Microsoft/Windows/CurrentVersion/Internet Settings"/V proxyenable/T REG_DWORD/d 00000000/F
Exit

@ REM ===================================================== ==========================================================
: Ip_t
CLS
Ping % testip %
Pause
CLS
Goto menu

@ REM ===================================================== ==========================================================
: Ip_t_nomenu
CLS
Ping % testip %
Pause
Exit
@ REM ===================================================== ==========================================================
: Ip_0
Netsh interface IP Set address % netconf % DHCP
Netsh interface IP Set DNS % netconf % DHCP
Exit

@ REM ===================================================== ==========================================================
: End
Netsh interface IP Set address name = % netconf % source = static ADDR = % myip % mask = % mymask %
Netsh interface IP Set address name = % netconf % gateway = % mygateway % gwmetric = 0
Netsh interface IP Set DNS name = % netconf % source = static ADDR = % dns1 % register = primary
Netsh interface IP add DNS name = % netconf % ADDR = % dns2 %
Netsh interface IP Set wins name = % netconf % source = static ADDR = none
Exit

--------------------------------------------------------------------------------
The description file is as follows:
--------------------------------------------------------------------------------

Easyip_readme.txt

About easyip

I. Origin
Easyip is an accidental idea. for work reasons, you need to change the IP address several times a day. Manual modification is slow and troublesome. I found a tool for changing the IP address on the Internet. The tool is quite convenient, but it is not very stable. The error message is displayed from time to time, and there are several files in the program, the occupied space is several megabytes.
Think about it, isn't it necessary to switch an IP address and an Internet Explorer proxy server?
Referring to an article by xbeta's http://www.xbeta.info: "There's no need to use a tool to quickly switch IP addresses" (http://blog.sina.com.cn/u/46dac66f010006gb ), I have also set up batch files for IP addresses in common locations, and it is very convenient to use them quickly using win + run. However, after a long time, the problem came again. After a while, there were a bunch of batch processing files that set IP addresses, and the registry files that set the proxy server. By chance, my colleague asked me casually that it would be convenient to merge so many files into one! I suddenly felt that it was indeed a good suggestion. I wrote the first version in batch that night. The reason for using batch processing is also very simple. In such a simple job, "how can it be used "?

Ii. Ideas
The program is very simple. You can use the netsh command to implement it. It is enough to add some parameters. At the beginning of the processing of the proxy server, a new registry file is created on drive C and then the Registry file is called for implementation. As the understanding of batch processing deepens, Reg is directly used in Versions later than 1.1, command to overcome the problem that errors will occur when no C disk is available, and it is more efficient and the code is more concise.

Iii. features:
1. Small
The entire program has only one file, and this file has only a few K!
2. Simple
Open all the code, right-click it and select "edit". Modify the relevant parameters as prompted to complete the settings of the program! Including menu content, network information, proxy server and so on.
3. Call with command line parameters added
For example, if you put the path in the path, you can directly use it by entering the easyip parameter in "run.

Iv. Upgrade history:
Major changes in v1.3. All parameters can be modified as variables. Currently, the most comprehensive and stable version is available.
V1.1 modified the Registry Modification Method; added support for command line parameters
The V1.0 program is basically complete and implements the most basic IP quick switch function.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.