Get the App
SLTechnology News&Howtos  ›  Network Security  › 

WIN7 sets IP, DNS, WINS through BAT script

Shulou Source: shulou.com Published: 2022-06-01 09:11:59 09月17日 Update

This article uses BAT script to set network information such as IP on WIN7. The following is an example:

The following is the script: @ echo off%1% 2ver | find "5." > nul&&goto: stmshta _ vbscript:createobject ("shell.application"). Shellexecute ("% ~ S0", "goto: st", "", "runas" 1) (window.close) & goto: eof:stecho/title modifies the native IP address color 1fecho * echo * * echo * modify the local Nic IP address * echo * 1. Static address * echo * 2. Automatically get * echo *: beginset / p n = Please enter the type of network card to be set (1 or 2): if "% n%" lss "1" echo the network card you entered does not exist! Please re-enter! If "n" gtr "2" echo the network card you entered does not exist! Please re-enter! Echo/if "n%" lss "1" goto beginif "% n%" gtr "2" goto beginif "n%" equ "1" goto x1if "% n%" equ "2" goto x2:x1echo you chose:% n. Ethernet: begin1set / p a = Please enter static IP address (e.g. 192.168.1.2): if "% a%" equ "goto begin1:begin2set / p b = enter subnet mask (e.g. 255.255.255.0): if"% b% "equ"goto begin2:begin3set / p c = enter gateway address (e.g. 192.168.1.1): if"% c% "equ"goto begin3:begin4set / p d = enter DNS Address 1 (e.g. 114.114.114.114): if "% d%" equ "goto begin4:begin5set / p e = Please enter DNS address 2 (e.g. 211.138.156.66): if"% e% "equ"goto begin5:begin6set / p f = Please enter WINS address (e.g. 8.8.8.8): if"% f% "equ"goto begin6netsh interface ip set address" Local connection "static% a% b% c%netsh interface ip set dns "Local connection" static d% primary > nulnetsh interface ip add dns "Local connection"% e% > nulnetsh interface ip set wins "Local connection" static% f% > nulecho static address set successfully!! ping-n 5 127.0.0.1 > nulgoto:eof:x2echo selected:% n. Automatic acquisition echo * echo * IP is about to be initialized to automatic acquisition state. * netsh interface ip set address "Local connection" dhcp > nulnetsh interface ip set dns "Local connection" dhcp > nulecho * echo DHCP set successfully!! ping-n 5 127.0.0.1 > nulgoto:eofpause

Tags: Input address network card static script success native selection Ethernet information status example type gateway network Ethernet subnet Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Apple Microsoft Shulou Tech Info MySQL