Question

I'm currently working on a project where I (among other things) need to find the MAC address for a remote computer. The problem is that i'm restriced to only accessing the computer throught SQL queries. (so I can't use WMI)

The remote computer is running Windows Server 2000, and Ms SQL server 2000.

I know the IP of the remote computer and I am able to log in with the admin account. How can I get the MAC address(preferably all of them) from the remote computer?

Thankful for answers.

Was it helpful?

Solution 3

I solved it for my computer

//dont mind the makeQuery and querySrv

ResultTable res = makeQuery(querySrv,("USE Master; EXEC xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\\Description\\Microsoft\\rpc\\UuidTemporaryData', 'NetworkAddress'"));
    byte[] bMac =(byte[])res.getRow(0).data[1];
    String mac = String.format("%02X:%02X:%02X:%02X:%02X:%02X", bMac[0], bMac[1], bMac[2], bMac[3], bMac[4], bMac[5]);

This should work for other windows server 2000 servers

Thanks to @morgano for help with the formating and byte/hex converting

OTHER TIPS

I think that some kind of external call via xp_cmdshell is your only option. There is a likelihood that this feature may be disabled on your SQL Server (with good reason).

Something like

 Create table #results(data varchar(250))
 Insert #results
 exec master..xp_cmdshell 'ipconfig /all'

 select * from #results where data like 'physical address%'

Further to your comment - you may find it under in the registry under the

HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}

key, but if and where will be hardware configuration dependent.

According to this, it doesn't seem you can. If you were using SQL Server 2005+, I'd think you could code up something in SQLCLR to do this without too much effort.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top