how to detect host id of a computer using excel

  • Thread starter Thread starter im281088
  • Start date Start date
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.
 
hi,

sHostName = Application.UserName

isabelle


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

sHostName2 = Environ$("computername")

isabelle

Le 2013-01-05 11:55, isabelle a écrit :
 
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
 
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.
 
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
 
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
 
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
 
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)?
 
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
 
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
 
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 )
)]]]]]]
 
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
 
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.
 
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?
 
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...
 
i don't agree, simply connect a modulo on the cpu of motherboard and
record anything else, but it is not vba, so ...

isabelle

Le 2013-01-05 22:47, CellShocked a écrit :
 
Hmmm. I doubt that UUID represents a machine specific value, because
the identical UUID appears in an example here:

http://include.wutils.com/wmi/ROOT\...ftwareElement/CIM_BIOSElement/Win32_BIOS.html


They have not implemented these things for a while. There must be some
way for a John Doe OEM Machne maker who buys Joe Bloe MOBO maker's cheap
run MOBO series in M quantities to go in and set these parameters.

I'd bet the main drawback is that each BIOS chip would have to be
individually burned with a unique code block, as opposed to mass burning
a bank of BIOS chips all at one time with the same code. But a modern
flash chip could do both. Burn the base code, and update the S/N later.
but that STILL requires individual chip attention and handling, as well
as the tracking aspect imposed on the maker.
 
CellShocked laid this down on his screen :
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?
Yes!

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?

Store the code in a standard module, but remove the Private scope
keyword. Read my other replies for sample of how to use it.

--
Garry

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