ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PC Serial number recall (https://www.excelbanter.com/excel-programming/437532-pc-serial-number-recall.html)

Alberto Ast[_2_]

PC Serial number recall
 
Is there a way to pull the PC serial number or PC user name preferable serial
number.... using vb so I can record it in a file indicating from which
computer the update was made?

Barb Reinhardt

PC Serial number recall
 
Try

environ("COMPUTERNAME")

or

environ("SERIAL")

--
HTH,

Barb Reinhardt



"Alberto Ast" wrote:

Is there a way to pull the PC serial number or PC user name preferable serial
number.... using vb so I can record it in a file indicating from which
computer the update was made?


GS

PC Serial number recall
 
<AFAIKEnviron() doesn't return a serial#.
Here's a reusable function that will return the manufacturer's BIOS serial
number of the computer the function is run on.

Function GetPC_SerialNo() As String
' Gets the serial number of a PC's BIOS

Dim sComputer As String, sSerialNo As String
Dim oWMI As Variant
Dim vSettings As Variant, vBIOS As Variant

sComputer = "winmgmts:{impersonationLevel=impersonate}!\\.\roo t\cimv2"
Set oWMI = GetObject(sComputer)
Set vSettings = oWMI.ExecQuery("Select * from Win32_BIOS")
For Each vBIOS In vSettings
GetPC_SerialNo = Trim(vBIOS.SerialNumber)
Next
End Function '//GetPC_SerialNo

HTH
Kind regards,
Garry

Alberto Ast[_2_]

PC Serial number recall
 
Serial did not work but computer name did. Thanks.

"Barb Reinhardt" wrote:

Try

environ("COMPUTERNAME")

or

environ("SERIAL")

--
HTH,

Barb Reinhardt



"Alberto Ast" wrote:

Is there a way to pull the PC serial number or PC user name preferable serial
number.... using vb so I can record it in a file indicating from which
computer the update was made?


Alberto Ast[_2_]

PC Serial number recall
 
Did work great... not I have serial and computer name.
Great learning today.
Thanks.

"GS" wrote:

<AFAIKEnviron() doesn't return a serial#.
Here's a reusable function that will return the manufacturer's BIOS serial
number of the computer the function is run on.

Function GetPC_SerialNo() As String
' Gets the serial number of a PC's BIOS

Dim sComputer As String, sSerialNo As String
Dim oWMI As Variant
Dim vSettings As Variant, vBIOS As Variant

sComputer = "winmgmts:{impersonationLevel=impersonate}!\\.\roo t\cimv2"
Set oWMI = GetObject(sComputer)
Set vSettings = oWMI.ExecQuery("Select * from Win32_BIOS")
For Each vBIOS In vSettings
GetPC_SerialNo = Trim(vBIOS.SerialNumber)
Next
End Function '//GetPC_SerialNo

HTH
Kind regards,
Garry


fisch4bill

PC Serial number recall
 
Environ("COMPUTERNAME") and Environ("USERNAME") should give you pretty
definitive information. (Not only the computer, but also the user.)
I didn't find a PC Serial Number in the Environment Variables

"Alberto Ast" wrote:

Is there a way to pull the PC serial number or PC user name preferable serial
number.... using vb so I can record it in a file indicating from which
computer the update was made?



All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com