Sys_GetMac
VB Scripting Library > OSD Scripting Library > System functions (OSD)
Sys_GetMac(sIP)
Section titled “Sys_GetMac(sIP)”Tries to resolve the Mac address for the given IP by ping and ARP cache lookup.
If successfull, the MAC address is returned in gsValue, otherwise gsValue returns empty string.
The MAC address is returned in lowercase with colons as separators, for example 00:1a:2b:3c:4d:5e.
Arguments
Section titled “Arguments”| ARGUMENT | DESCRIPTION | TYPE |
|---|---|---|
| sIP | The IP address to resolve into a mac address. Must be an IPv4 address. | String |
Return Type
Section titled “Return Type”Boolean, TRUE if function completed successfully.
Remarks
Section titled “Remarks”- The ARP cache only holds addresses on the local subnet, so the MAC address can only be resolved for computers on the same subnet, such as the default gateway.
- If sIP isn’t a valid IPv4 address, gsValue returns an empty string.
- OSD_Initialize calls this function and stores the MAC address of the default gateway in gsGatewayMac and of the boot server in gsBootserverMac.
Example
Section titled “Example”The following example will try to resolve the mac address for the default gateway.
Private Function IncludeScript(sScriptFile) '...End Function
'Begin bStatus=True If bStatus Then bStatus=IncludeScript("customlib.cis") If bStatus Then bStatus=IncludeLibrary("Capalib.cin") If bStatus Then bStatus=IncludeLibrary("Osdlib.cin") If bStatus Then bStatus=Job_Start("WS","Script Name","1.0","ScriptName.log","INSTALL") If bStatus Then bStatus=OSD_Initialize()
If bStatus Then bStatus=Net_GetAdapterInfo() If bStatus Then bStatus=Reg_GetString("HKLM","SOFTWARE\CapaSystems\CapaInstaller\Client\Inv","DefaultGateway",false) If bStatus and gsValue <> "" Then sGatewayIP=gsValue If bStatus Then bStatus=Sys_GetMac(sGatewayIP) If bStatus and gsValue <> "" Then bStatus=Dialog_ShowInformation("Your default gateways mac address is: " & gsValue)
Job_End(bStatus)'End mainSee Also
Section titled “See Also”Scripting Guidelines, Net_GetAdapterInfo, Dialog_ShowInformation Constants Package Property Variables