Batch Processing of binding local IP addresses and Mac and gateway IP addresses and MAC addresses

Source: Internet
Author: User
Macb0nd. batrem @ echo off
Rem reads the MAC address of the Local Machine
If exist ipconfig.txt del ipconfig.txt
Ipconfig/All> ipconfig.txt
If exist phyaddr.txt del phyaddr.txt
Find "physical address" ipconfig.txt> phyaddr.txt
For/F "Skip = 2 tokens = 12" % m in (phyaddr.txt) do set MAC = % m
Rem reads the local IP Address
If exist ipaddr.txt del ipaddr.txt
Find "ip address" ipconfig.txt> ipaddr.txt
For/F "Skip = 2 tokens = 15" % I in (ipaddr.txt) do set IP = % I
Rem binds the local IP address and MAC address
ARP-S % IP % Mac %
REM read gateway address
If exist already ip.txt del already ip.txt
Find "Default Gateway" ipconfig.txt> gateip.txt
For/F "Skip = 2 tokens = 13" % G in (ip.txt) do set destination IP = % G
REM read gateway MAC address
If exist gatemac.txt del gatemac.txt
ARP-A % slave IP %> gatemac.txt
For/F "Skip = 3 tokens = 2" % H in (gatemac.txt) do set hosts MAC = % H
Rem binding gateway Mac and IP
ARP-S % gateip % gatemac %
Del ipconfig.txt
Del phyaddr.txt
Del ipaddr.txt
Del paiip.txt
Del gatemac.txt
Rem exit

Vbs script in startup

Dim objshell
Set objshell = wscript. Createobject ("wscript. Shell ")
Rem wscript. Sleep (10000)
Ireturn = objshell. Run ("cmd.exe/C" "D: \ Program Files \ macb0nd. Bat", 0, true)

Result of ARP-A after binding
Interface: 192.168.8.20.--- 0x3
Internet address physical address type
192.168.8.1 00-d0-88-04-f2-5c static
192.168.8.000000-e0-4c-58-e2-d6 static
Vbsset Ws = wscript. Createobject ("wscript. Shell ")
Do
WS. Run "C: \ 0.bat", 0
Wscript. Sleep (10000)
Loop

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.