473,385 Members | 2,274 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,385 software developers and data experts.

Get MAC-ID,User Name without WMI

75
Hi All,
How to get the User Name and Mac-id of a pc using a button click in Visual Basic 2005.This has to be done without using WMI.
Jan 8 '07 #1
2 5202
Hi All,
How to get the User Name and Mac-id of a pc using a button click in Visual Basic 2005.This has to be done without using WMI.

You haven't provided a lot of information here .... so I'm just going to make some guesses:

1. You are running XT
2. You only have one MAC address in the workstation

Note: I've had similar issues - so in the past we wrote a server program that would strip the IP packet apart and return a response containing the MAC address. That being said - the may be an easier way.

A. Shell out and run the ipconfig.exe program (C:\windows\system32\ipconfig.exe /all) redirecting the output to a text file. Parse this file apart looking for the line(s) Physical Address.

User name is a bit easier ... in VBA its UserName = Environ("USERNAME")

Hope this helps.
Jan 8 '07 #2
For MAC address try this without any parsing, note GetMAC instead of ipconfig /all ( With body is a recorded and adapted Macro) :

'-----------------------------------------------------------------------------
Private Sub CommandButton_Click()
Dim str, f, fs, cmd

str = CurDir & "\" & "tempfile.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile(str, True)
f.Close
str = CurDir & "\"
Set sh = CreateObject("WScript.Shell")

sh.CurrentDirectory = str

sh.Exec "%COMSPEC% /k GetMAC > tempfile.txt"

str = str & "tempfile.txt"
MsgBox str

str = "TEXT;" & str
Worksheets("Foglio1").Activate

With ActiveSheet.QueryTables.Add(Connection:=str, Destination:=Range("A1"))
.Name = "tempfile"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 2
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.TextFileFixedColumnWidths = Array(20)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

'-------------------------------------------------------------------------------------------------------

I hope you like !
Jan 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: YAN | last post by:
Hi, I want to get the mac address from a machine, which i have the IP address of that machine, how can i do that? I know how to get the mac address of the local machine from the following code: ...
0
by: spe.stani.be | last post by:
SPE (Stani's Python Editor) is an open-source python IDE with auto indentation & completion, call tips, syntax coloring & highlighting, UML diagrams, class explorer, source index, auto todo list,...
4
by: VK | last post by:
Is there by any chance someone using IE 5.x under Mac OS 8.x - X ? You would like to know if FileSystemObject ActiveX control is supported under Mac OS. MSDN is rather ambiguous on this matter,...
22
by: Andy Dingley | last post by:
http://www.microsoft.com/mac/products/internetexplorer/internetexplorer.aspx?pid=internetexplorer Microsoft will end support for Internet Explorer for Mac on December 31st, 2005, and will provide...
9
by: James Vanns | last post by:
First, Sorry for the cross-post :p OK, in Linux I can obtain the MAC address using socket(), ioctl() etc. and a few data structures. No problem. However, the resulting MAC is stored in a 14 byte...
4
by: VB Programmer | last post by:
First, I apologize to Mac-haters... :) I know that there are some software packages, like Parralel Desktop for Mac, that let you run XP on a Mac. Does anyone know if Visual Studio.net, IIS,...
17
by: Ravi | last post by:
Hey any body knows how can i find my system mac address using php. it's very urgent..... thanks in advance Ravindra.Y
5
by: Peggy | last post by:
Hello, I have a web application running on IIS, What I wanna do is to obtain server's ethernet card's mac address in order to use this address for licensing issues I have developed my web...
9
by: VB Programmer | last post by:
I am an ASP.NET (VB.NET) web developer, using MS Visual Studio. I'm thinking of switching over to MAC. I was wondering if anyone is using Visual Studio 2005 or 2008 beta in a XP or Vista...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.