pankajtakawale Posted March 20, 2007 Posted March 20, 2007 Is there any command, wmi script or api which returns the NIC info (mac addr) from which WinPE has been network booted on?example:If I have multiple NICs and each NIC is attached to different subnet.I have configured NIC1 at the 1st position of boot loader in BIOS and NIC2 at 2nd position.Say, DHCP server is not present on NIC1 network, and its present on NIC2 n/w.so obviously my WinPE will be network booted from NIC2.Is there any api, command, WMI query to information about n/w adapter from which WInPE has been booted on (in this case NIC2)?Pankaj.
uid0 Posted March 20, 2007 Posted March 20, 2007 I read this somewhere:@ECHO OFFipconfig/all | FIND /I "IP Address">> IP.txtfor /f " tokens=14* delims=, " %%i in (IP.txt) DO SET IPAddress=%%jNBTSTAT -a %IPAddress% | FIND /I "MAC Address">> net.txtfor /f " tokens=3* delims=, " %%i in (net.txt) DO SET MACAddress=%%jecho %MACAddress%>> mac.txtdel net.txt;ip.txtecho %MACAddress%pause(Not tried it)
pankajtakawale Posted March 21, 2007 Author Posted March 21, 2007 Im confused how would it (nbtstat) help?Just another case:machine has 2 NICs NIC1 & NIC2NIC1 is on n/w 1 and NIC2 is on n/w 2.Both n/ws have DHCP server running.NIC1 has priority over NIC2 in BIOS boot loading.I have configured WinPE network booting on n/w 2 (to which NIC2 is connected)Once machine boots up, NIC1 gets ipaddress from DHCP server of n/w 1.NIC2 gets ipaddress from DHCP server of n/w 2 and also it receives boot-server & boot-filename details. It starts booting WinPE.Now in above case, WinPE has been booted on NIC2.How can i detect it thru any command, api from WinPE?
ubernerd Posted March 21, 2007 Posted March 21, 2007 The DHCP/PXE reply that WinPE is booted from is stored in the registryHKLM\SYSTEM\CurrentControlSet\Control\PXE, in this block of bytes you can find the IP address used to boot WinPEOnce you have that scan thru Win32_NetworkAdapters in WMI and find the NIC with the IP address you found in ther previous stepGet the MAC address property of the win32_NetworkAdapter and you're done.All theses steps can be done using vbscript.
pankajtakawale Posted March 22, 2007 Author Posted March 22, 2007 Thnx for valuable info.I checked the above mentioned PXE registry key.It has 2 binary values: "BootServerReply" and "DHCPServerACK"binary values contain hell lot of info, probably whole DHCPOFFER and DHCPACK packets. Any idea how to extract info from these binary values?
ubernerd Posted March 24, 2007 Posted March 24, 2007 WMI has a class for handling registry, and it has a method for reading binary values into an array. From there on its plain vbscript coding
trent_steele Posted April 19, 2007 Posted April 19, 2007 VBScript to get MAC Address using WMI:strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colItems = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapter")For Each objItem in colItems GetMACAddress = objItem.MACAddressNextWorks under Win PE 2.0.
mats Posted April 24, 2007 Posted April 24, 2007 One way is to look at hklm\system\currentcontrolset\control\systembootdevice or Remotebootmachinedirectory.That will give you the name of the RIS server. That in turn would tell you from wich network your machine booted and if nic2 always is net2 when we have a souloution.IF we can't be sure on this I would check the ip addresses of the box and see wich one that matches the network of the server
Br4tt3 Posted May 4, 2007 Posted May 4, 2007 One way is to look at hklm\system\currentcontrolset\control\systembootdevice or Remotebootmachinedirectory.That will give you the name of the RIS server. That in turn would tell you from wich network your machine booted and if nic2 always is net2 when we have a souloution.IF we can't be sure on this I would check the ip addresses of the box and see wich one that matches the network of the serverHi Mats!I assume u r talking about WinPE 2.0, is that correct? When checking out my own WinPE 2.0 image which is booted from a WDS box, the above mentioned reg entries cannot be found!! Then again, u r writing RIS server so I dont know if this applied to WDS/PE 2.0 as well.....
mats Posted May 4, 2007 Posted May 4, 2007 Sorry Br4tt3Only applies to 1.x booted frpm ris. It doesn't work on any type of /inram booted pe and 2.0 uses inram as default.On a 2.0 i suspect we would have to check the ip against a list of subnets
osm Posted December 31, 2008 Posted December 31, 2008 The fastest way to get the MAC Address(es) in WinPE 2.x is: For /F "tokens=12* delims= " %i IN ('ipconfig /all ^| find /I "Physical Address"') DO echo %i
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now