gparmar Posted October 25, 2005 Posted October 25, 2005 Hello,I have been looking out for a vb script or a s/w tool which will assign a specific IP based on the MAC address it reads from a txt file.help me achieve this. it's very important to me.any tools/how to/guides.thanks in advance
jjvs Posted November 14, 2005 Posted November 14, 2005 Hi gparmar,I think this cmd file should do the trick@ECHO OFFSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONREM Set the subnetmaskSET NETMASK=255.255.255.0REM Retrieve "adapter name" & mac address using ipconfigFOR /F "DELIMS=" %%M in ('IPCONFIG.EXE /ALL') DO @( SET LINE=%%M FOR /F "TOKENS=1" %%A IN ("!LINE!") DO @( IF X%%A==XEthernet ( SET ADAPTER=!LINE:Ethernet adapter =! SET ADAPTER=!ADAPTER::=! SET MAC= ) ELSE IF X%%A==XPhysical ( SET MAC=!LINE:* : =! REM Use Adapter with double quotes to submit full adaptername as 1 parameter CALL :SET_IP !MAC! "!ADAPTER!" ) ))GOTO END:SET_IPREM Read MAC & IP addresses from file, and if MAC is %1 set IPFOR /F "TOKENS=1,2" %%I IN ('TYPE "%~dp0\mac2ip.txt"') DO IF %%I==%1 SET IP=%%JIF DEFINED IP ( REM Update IP address for adapter NETSH INTERFACE IP SET ADDRESS STATIC NAME=%2 %IP% %NETMASK%) ELSE ( ECHO MAC Address not found in %~dp0\mac2ip.txt)GOTO END:ENDIt reads the text file mac2ip.txt which should be in the same directory as this cmd file. And the text file looks something like this:# MAC Address IP Address00-AA-11-BB-22-CC 10.10.10.10100-DD-11-EE-22-FF 10.10.11.10100-11-22-33-44-55 10.10.12.101It can handle multiple ethernet adapters on one computer.Good luck with it
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now