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