473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

What's the easiest way to read a MAC address 'n suck it into MS Access?

MLH
I would like to read a MAC address from at least one NIC
in a PC on which I have an Access 97 runtime app installed.
What's the least hassel method you know of?
Nov 13 '05 #1
7 2113
MLH <CR**@NorthState.net> wrote in news:pdrac1h2ididiqa9l7ej0j7ee2fvvo7308@
4ax.com:
I would like to read a MAC address from at least one NIC
in a PC on which I have an Access 97 runtime app installed.
What's the least hassel method you know of?


Knock three times on the ceiling ...
Nov 13 '05 #2
MLH <CR**@NorthState.net> wrote in
news:pd********************************@4ax.com:
I would like to read a MAC address from at least one NIC
in a PC on which I have an Access 97 runtime app installed.
What's the least hassel method you know of?


There's code here:

http://vbnet.mvps.org/index.html?cod...macaddress.htm

that does the job via NetBIOS. It's based on this MS Knowledge Base
article:

http://www.codeguru.com/resources/Network/

Note, however, that it will fail if the local machine has TCP/IP
over NetBIOS turned OFF (as anyone connected to the Internet and
running TCP/IP really ought to; otherwise your computer ends up with
a half dozen ports open to the Internet, none of which are useful
for anything other than exposing you to nasties out there on the
Internet). If NetBIOS over TCP/IP is turned off, the function there
returns 0.0.0.0.

I was able to get the code here to work with NetBIOS turned off:

http://vbnet.mvps.org/index.html?cod...ressremote.htm

I didn't think it *would*, since it said it as for remote IP
addresses, but it reported the same MAC Address as shows up in
ipconfig /all for my NIC. Note that it doesn't work with passing
127.0.0.1 (the loopback address).

The mention of ipconfig raises the alternative I had thought of
before Googling, which is to use shell to redirect ipconfig /all to
a text file, then open that text file and hunt for the line that
indicates Physical Address: -- but I don't do file I/O, so I can't
demonstrate how to use that.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #3
MLH
Well, there you go! I didn't read your post as thoroughly as I
should have. I didn't notice the /all parm on the ipconfig command.
Will that always return the hard coded address on the current NIC?
I sure hope so. If its that simple, I'm good to go. Many thx Mr
Fenton!

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I didn't think it *would*, since it said it as for remote IP
addresses, but it reported the same MAC Address as shows up in
ipconfig /all for my NIC. Note that it doesn't work with passing
127.0.0.1 (the loopback address).

The mention of ipconfig raises the alternative I had thought of
before Googling, which is to use shell to redirect ipconfig /all to
a text file, then open that text file and hunt for the line that
indicates Physical Address: -- but I don't do file I/O, so I can't
demonstrate how to use that.


Nov 13 '05 #4
MLH
Big thanks for the heads up on shelling out to run ipconfig /all.
Its likely the most reliable option. IPconfig will return a MAC addr
even when he cable is disconnected and netbios is NOT running.
I think that's gonna be he ticket!

BTW, how exactly does one pass a command like this
ipconfig /all > c:\mydir\myfile.txt
to a DOS window via the VBA Shell command? Do I
run something like this...
Dim RetVal
RetVal = Shell("c:\windows\system32\cmd.exe", 0)
And then use sendkeys to handle the
ipconfig /all > c:\mydir\myfile.txt
part? If that's the only way, I guess I'll write a DOS batch file
to run ipconfig /all > c:\mydir\myfile.txt and name it z~.bat or
something short 'n sweet.

I can handle the rest of it, opening a file for input, reading &
parsing to get what I want.

The mention of ipconfig raises the alternative I had thought of
before Googling, which is to use shell to redirect ipconfig /all to
a text file, then open that text file and hunt for the line that
indicates Physical Address: -- but I don't do file I/O, so I can't
demonstrate how to use that.


Nov 13 '05 #5
On Sun, 03 Jul 2005 10:09:51 -0400, MLH <CR**@NorthState.net> wrote:
Big thanks for the heads up on shelling out to run ipconfig /all.
Its likely the most reliable option. IPconfig will return a MAC addr
even when he cable is disconnected and netbios is NOT running.
I think that's gonna be he ticket!

BTW, how exactly does one pass a command like this
ipconfig /all > c:\mydir\myfile.txt
to a DOS window via the VBA Shell command? Do I
run something like this...
Dim RetVal
RetVal = Shell("c:\windows\system32\cmd.exe", 0)
And then use sendkeys to handle the
ipconfig /all > c:\mydir\myfile.txt
part? If that's the only way, I guess I'll write a DOS batch file
to run ipconfig /all > c:\mydir\myfile.txt and name it z~.bat or
something short 'n sweet.

I can handle the rest of it, opening a file for input, reading &
parsing to get what I want.

Hi
see other thread, but here is a copy: one way is-

1. Create a file C:\getconfig.bat consisting of

ipconfig /all >C:\config.txt

You can do this in code as required or make sure one is on the
machine.

Some batch commands, and I'm not sure whether ipconfig is one of them,
don't work properly from the run command but only from the "dos"
window,

2. launch this file using ShellWait (see http://www.mvps.org) (or just
shell out and doevents and wait a few seconds). Run it minimised.

3. open the file config.txt and parse out the information you want.
(Easier said than done, look for lines "physical address".However not
obvious which one is primary NIC. Also I'm not sure this is abolutely
always the physical address though it probably is.)

In the above instead of C: you should really get a suitable path, eg
use apiGetTempDir (also at http://www.mvps.org) though C:\temp would
probably be OK.

also there may be a different option to /all which gives you more
exactly what you need from ipconfig

4. Never use sendkeys.

I still think this is all too complicated!

David

Nov 13 '05 #6
MLH
yeah, I found out the hard way before reading this post.
Lots of wierd stuff (including loss of keyboard) - w/o any error
reported.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

4. Never use sendkeys.

I still think this is all too complicated!

David


Nov 13 '05 #7
MLH <CR**@NorthState.net> wrote in
news:ek********************************@4ax.com:
Big thanks for the heads up on shelling out to run ipconfig /all.
Its likely the most reliable option. IPconfig will return a MAC
addr even when he cable is disconnected and netbios is NOT
running.


What about when the NIC is disabled?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
1
by: wASP | last post by:
Hi, I'm a newbie starting up with ASP.NET, and I'm getting off to a wonderful start - and when I tell you "wonderful" I'm being sarcastic. My OS is Win 2000 SP4 - and I'm using IE6. I've...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
10
by: Nathaniel Branden | last post by:
Hello. This isn't really an Access question. I just want to know whether Tony Toews is retarded. In that vain, I have pasted down his last thirty or so posts for someone out there to respond. ...
24
by: Bob Alston | last post by:
Most of my Access database implementations have been fairly small in terms of data volume and number of concurrent users. So far I haven't had performance issues to worry about. <knock on wood> ...
9
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in...
50
by: lovecreatesbea... | last post by:
Could you extract examples of the characteristics of C itself to demonstrate what the advantages of C are? What are its pleasant, expressive and versatile characteristics? And what are its...
14
by: salad | last post by:
XML seems to be a hot technology buzzword. And it appears XML is supported in A2003. I am wondering if it could be used in the following scenario. I create an order record for the customer. ...
33
by: James H. Newman | last post by:
I have a portion of code along the following lines: volatile unsigned char x ; unsigned int f(unsigned char *y) ; When I do unsigned int z = f(&x) ;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.