Reference: http://caoxuhuan.iteye.com/blog/973625
Because the dormitory and lab must be bound with the static IP address of the machine to access the Internet, it is very troublesome to manually change the IP address and gateway in the "Network and sharing center, so I want to have an automated method for processing. The best solution is to have two icons on the desktop. Double-click any icon to easily complete the network configuration.
Step 1: understand the principle of automatically setting IP addresses. Run the following command in cmd:
Netsh interface IP Set address name = "Local Area Connection" Source = static ADDR = 192.168.104.67 mask = 255.255.255.0 gateway = 192.168.200.11 modify the above command to set it to the corresponding IP address. in this example, cmd.exe needs to run as administrator.
Step 2: Package the command into a bat file Enter a new TXT file in any folder: Netsh interface IP Set address name = "Local Area Connection" Source = static ADDR = 192.168.104.67
Mask = 255.255.255.0 gateway = 192.168.200.11 Save and exit. Then change the suffix of the. txt file to. bat. Send the. BAT file to the desktop. Right-click the. Bat shortcut icon on the desktop and choose Properties. On the shortcut cut tab, click Advanced... to check the run as administrator. Save and exit. In this way, every time you double-click the XXX. BAT file on the desktop, it will log on with the Administrator's identity card and automatically set the IP address and gateway.