how to detect host id of a computer using excel

I

im281088

I want to create a file which is locked to host id of computer. can anyone tell me how to detect host id of a computer in excel.
 
I

isabelle

hi,

sHostName = Application.UserName

isabelle


Le 2013-01-05 11:33, (e-mail address removed) a écrit :
 
I

isabelle

also,

sHostName2 = Environ$("computername")

isabelle

Le 2013-01-05 11:55, isabelle a écrit :
 
G

GS

try...

Private Function Get_BIOSserialNum() As String
' Gets the serial number of a PC's BIOS
Dim oWMI As Variant, vSettings As Variant, vBIOS As Variant

Const sComputer$ = _
"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"
Set oWMI = CreateObject(sComputer)
Set vSettings = oWMI.ExecQuery("Select * from Win32_BIOS")
For Each vBIOS In vSettings
Get_BIOSserialNum = Trim(vBIOS.SerialNumber): Next
End Function '//Get_BIOSserialNum

...note, though, that some clones won't have a serial number and so
you'll need to handle what to do in this case.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
C

CellShocked

try...

Private Function Get_BIOSserialNum() As String
' Gets the serial number of a PC's BIOS
Dim oWMI As Variant, vSettings As Variant, vBIOS As Variant

Const sComputer$ = _
"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"
Set oWMI = CreateObject(sComputer)
Set vSettings = oWMI.ExecQuery("Select * from Win32_BIOS")
For Each vBIOS In vSettings
Get_BIOSserialNum = Trim(vBIOS.SerialNumber): Next
End Function '//Get_BIOSserialNum

..note, though, that some clones won't have a serial number and so
you'll need to handle what to do in this case.


Where do I place a private function? I have not previously ever
defined one.

So far, the macro area of my worksheet does not do it.

And how do I call it? no arguments, right? Just =call() in the
cell and it resolves?

So far I get a name error. I have yet to place it in the right
location so that it shows up in the function list.
 
R

Ron Rosenfeld

I want to create a file which is locked to host id of computer. can anyone tell me how to detect host id of a computer in excel.

Here's a routine to obtain the MACAddress, from http://www.ehow.com/how_6920281_use-vba-mac-address.html

============================
Option Explicit
Function GetMACAddress()
Dim objVMI As Object
Dim vAdptr As Variant
Dim objAdptr As Object
Dim adptrCnt As Long
Dim GetNetworkConnectionMACAddress As String
Set objVMI = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set vAdptr = objVMI.execquery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For Each objAdptr In vAdptr
If Not IsNull(objAdptr.MACAddress) And IsArray(objAdptr.IPAddress) Then
For adptrCnt = 0 To UBound(objAdptr.IPAddress)
If Not objAdptr.IPAddress(adptrCnt) = "0.0.0.0" Then
GetNetworkConnectionMACAddress = objAdptr.MACAddress
Exit For
End If
Next adptrCnt
MsgBox "Your MAC Address is: " & GetNetworkConnectionMACAddress
End If
Next objAdptr

End Function
======================================
 
G

GS

The function is scoped Private because it belongs to my licensing
component. You can delete that keyword.

The function is not designed to be called/use on a worksheet. It should
be called from another Sub in a standard module. Also, the function
should reside in a standard module. To use it...

Range("A1").Text = Get_BIOSserialNum

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
G

GS

I recommend using WMI to obtain the BIOS serial number because all the
values recommended by you and Isabelle (thus far) can be
edited/changed. The only way to change the BSN is to replace the
motherboard. In the case of a clone machine returning an empty BSN, I
substitute with a hash value of that empty string via SHA256. When this
is combined with make & model it serves well enough for my purposes.<g>

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
R

Ron Rosenfeld

I recommend using WMI to obtain the BIOS serial number because all the
values recommended by you and Isabelle (thus far) can be
edited/changed. The only way to change the BSN is to replace the
motherboard. In the case of a clone machine returning an empty BSN, I
substitute with a hash value of that empty string via SHA256. When this
is combined with make & model it serves well enough for my purposes.<g>

I agree with what you have written in terms of identification of a specific machine. However, the OP requested a method for obtaining the "Host ID". The various definitions I have seen for Host ID have been satisfied by the MAC address (or IP address) in Windows machines. I believe that is also the case for Unix machines (see hostid command).
 
R

Ron Rosenfeld

I recommend using WMI to obtain the BIOS serial number because all the
values recommended by you and Isabelle (thus far) can be
edited/changed. The only way to change the BSN is to replace the
motherboard. In the case of a clone machine returning an empty BSN, I
substitute with a hash value of that empty string via SHA256. When this
is combined with make & model it serves well enough for my purposes.<g>

Oh, and my machine is built by myself; your routine returns "To Be Filled By O.E.M." (Which is what is in all the Chassis Information slots except for Type: Desktop)
 
G

GS

Ron Rosenfeld used his keyboard to write :
I agree with what you have written in terms of identification of a specific
machine. However, the OP requested a method for obtaining the "Host ID".
The various definitions I have seen for Host ID have been satisfied by the
MAC address (or IP address) in Windows machines. I believe that is also the
case for Unix machines (see hostid command).

No argument! The MAC address can be edited/changed and so if this
occurs it will break the methodology the OP is trying to implement.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
C

CellShocked

Oh, and my machine is built by myself; your routine returns
"To Be Filled By O.E.M." (Which is what is in all the Chassis
Information slots except for Type: Desktop)


Is there not a way to acquire the CPU ID (in Intel cases where it is
not turned off in the BIOS)?
 
G

GS

After serious thinking Ron Rosenfeld wrote :
Oh, and my machine is built by myself; your routine returns "To Be Filled By
O.E.M." (Which is what is in all the Chassis Information slots except for
Type: Desktop)

Interesting that this is the stored value. Obviously this is different
than what's returned in a commercial unit. For example, I find it
typical of clone machines released by Gateway to return an empty
string. Your case is a new one for me!<g>

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
G

GS

It happens that CellShocked formulated :
Is there not a way to acquire the CPU ID (in Intel cases where it is
not turned off in the BIOS)?

For all intents and purposes, the BIOS serial number IS the cpu's ID.
The only way to change it is to swap out the motherboard, which creates
a new cpu with a new ID.<g>

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
C

CellShocked

Ron Rosenfeld used his keyboard to write :

No argument! The MAC address can be edited/changed and so if this
occurs it will break the methodology the OP is trying to implement.


How do I call this: (remember to paste it all back together right)

[[[[[[dotnet.loadAssembly @"System.Management.dll"
mc = dotNetObject "System.Management.ManagementClass" "Win64_Processor"
moc = dotNetClass "System.Management.ManagementObjectCollection"
moc = mc.GetInstances()
enumerator = moc.GetEnumerator()
while enumerator.MoveNext() do
(
mo = enumerator.current
append CPUID ( mo.Properties.Item["ProcessorId"].value )
)]]]]]]
 
G

GS

CellShocked explained :
How do I call this: (remember to paste it all back together right)

[[[[[[dotnet.loadAssembly @"System.Management.dll"
mc = dotNetObject "System.Management.ManagementClass" "Win64_Processor"
moc = dotNetClass "System.Management.ManagementObjectCollection"
moc = mc.GetInstances()
enumerator = moc.GetEnumerator()
while enumerator.MoveNext() do
(
mo = enumerator.current
append CPUID ( mo.Properties.Item["ProcessorId"].value )
)]]]]]]

This is dotnet code and so won't work with VBA. Use the code I posted
here earlier...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
C

CellShocked

It happens that CellShocked formulated :

For all intents and purposes, the BIOS serial number IS the cpu's ID.
The only way to change it is to swap out the motherboard, which creates
a new cpu with a new ID.<g>


This claim is not true.

Intel CPUs have a unique identifier number which can be accessed though
their API. The motherboard serial number is an entirely different
animal, and BOTH numbers can be changed by way of changing either the CPU
itself, or the BIOS chip itself. some motherboards have a separate,
fixed chip which the real BIOS chip 'reads' to assign certain variables
in its operation. So, on those MOBOs, you will not change that ID
easily.
 
C

CellShocked

CellShocked explained :
How do I call this: (remember to paste it all back together right)

[[[[[[dotnet.loadAssembly @"System.Management.dll"
mc = dotNetObject "System.Management.ManagementClass" "Win64_Processor"
moc = dotNetClass "System.Management.ManagementObjectCollection"
moc = mc.GetInstances()
enumerator = moc.GetEnumerator()
while enumerator.MoveNext() do
(
mo = enumerator.current
append CPUID ( mo.Properties.Item["ProcessorId"].value )
)]]]]]]

This is dotnet code and so won't work with VBA. Use the code I posted
here earlier...


Your code? On a 64 bit system? And what about answering the question
where I asked just how to store that code in the excel VB editor (where)
and how to call it?
 
C

CellShocked

Intel CPUs have a unique identifier number which can be accessed though
their API. The motherboard serial number is an entirely different
animal, and BOTH numbers can be changed by way of changing either the CPU
itself, or the BIOS chip itself. some motherboards have a separate,
fixed chip which the real BIOS chip 'reads' to assign certain variables
in its operation. So, on those MOBOs, you will not change that ID
easily.

CORRECTION: (Ooops)

According to Intel, it has not been implemented since the i386.

http://www.intel.com/content/dam/ww...sor-identification-cpuid-instruction-note.pdf

So, the BIOS ID thing is very likely the only unique identifier
mechanism for a machine.

Makes me wonder what my iPad reads when examining its underpinnings...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top