ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Environmental Variables (https://www.excelbanter.com/excel-programming/430771-environmental-variables.html)

John G.[_2_]

Environmental Variables
 

Is there a envstring for the Environ() function that will return a unique
value, such as a serial # of the processor, Windows, Office, etc?

I want to setup some type of security should the XLS and not the XLT be
copied for use on another computer. I have no problem with the copying, it's
just that there will be CC info stored in the existing XLS file and I don't
want that to be distributed.
If I can check for two or three unique serials, I can have the routine clear
the existing data and reset the XLS to it's original delivered status. By
having more than one serial # to check, I can make sure the reset won't
happen should a minor hardware swap take place.

Sometime ago, I worked on a project in FoxPro where the code used a primary
harddrive serial # as a seed for an activation code. Was look for a similar
avenue if it's not too complicated.
Thx, JG

Jacob Skaria

Environmental Variables
 
ENVIRON() gives you the UserName , ComputerName. Will help ??

Msgbox Environ("UserName")
Msgbox Environ("ComputerName")


If this post helps click Yes
---------------
Jacob Skaria


"John G." wrote:

Is there a envstring for the Environ() function that will return a unique
value, such as a serial # of the processor, Windows, Office, etc?

I want to setup some type of security should the XLS and not the XLT be
copied for use on another computer. I have no problem with the copying, it's
just that there will be CC info stored in the existing XLS file and I don't
want that to be distributed.
If I can check for two or three unique serials, I can have the routine clear
the existing data and reset the XLS to it's original delivered status. By
having more than one serial # to check, I can make sure the reset won't
happen should a minor hardware swap take place.

Sometime ago, I worked on a project in FoxPro where the code used a primary
harddrive serial # as a seed for an activation code. Was look for a similar
avenue if it's not too complicated.
Thx, JG


John G.[_2_]

Environmental Variables
 

Jacob, thx for the reply.

I have run through the whole list of envstring, those two in particular, and
don't see any problem using those just was wondering if there's a function
that might get me a little deeper, ie, serial #'s.

JG

"Jacob Skaria" wrote:

ENVIRON() gives you the UserName , ComputerName. Will help ??

Msgbox Environ("UserName")
Msgbox Environ("ComputerName")


If this post helps click Yes
---------------
Jacob Skaria


"John G." wrote:

Is there a envstring for the Environ() function that will return a unique
value, such as a serial # of the processor, Windows, Office, etc?

I want to setup some type of security should the XLS and not the XLT be
copied for use on another computer. I have no problem with the copying, it's
just that there will be CC info stored in the existing XLS file and I don't
want that to be distributed.
If I can check for two or three unique serials, I can have the routine clear
the existing data and reset the XLS to it's original delivered status. By
having more than one serial # to check, I can make sure the reset won't
happen should a minor hardware swap take place.

Sometime ago, I worked on a project in FoxPro where the code used a primary
harddrive serial # as a seed for an activation code. Was look for a similar
avenue if it's not too complicated.
Thx, JG


John G.[_2_]

Environmental Variables
 

I found this code but it only seems to produce the disk partitiion ID's and
not motherboard, processor, and bios.

It it even possible?

Private Sub GetSerials()
Dim List, Msg, Object
On Local Error Resume Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_BaseBoard")
For Each Object In List
Msg = Msg & "Motherboard Serial Number: " & Object.SerialNumber & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_Processor")
For Each Object In List
Msg = Msg & "Processor Unique ID: " & Object.UniqueID & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_BIOS")
For Each Object In List
Msg = Msg & "BIOS Serial Number: " & Object.SerialNumber & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_LogicalDisk")
For Each Object In List
Msg = Msg & "Disk Serial Number: " & Object.VolumeSerialNumber & vbCrLf
Next

MsgBox Msg

End Sub


"John G." wrote:

Is there a envstring for the Environ() function that will return a unique
value, such as a serial # of the processor, Windows, Office, etc?

I want to setup some type of security should the XLS and not the XLT be
copied for use on another computer. I have no problem with the copying, it's
just that there will be CC info stored in the existing XLS file and I don't
want that to be distributed.
If I can check for two or three unique serials, I can have the routine clear
the existing data and reset the XLS to it's original delivered status. By
having more than one serial # to check, I can make sure the reset won't
happen should a minor hardware swap take place.

Sometime ago, I worked on a project in FoxPro where the code used a primary
harddrive serial # as a seed for an activation code. Was look for a similar
avenue if it's not too complicated.
Thx, JG


Jacob Skaria

Environmental Variables
 
To get serial number of mother board; try the below function..

Public Function MBSerialNumber() As String
Dim objs As Object, obj As Object, objWM As Object
Set objWM = GetObject("WinMgmts:")
Set objs = objWM.InstancesOf("Win32_BaseBoard")
For Each obj In objs
MBSerialNumber = "," & MBSerialNumber & obj.SerialNumber
Next
MBSerialNumber = Mid(MBSerialNumber, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"John G." wrote:

I found this code but it only seems to produce the disk partitiion ID's and
not motherboard, processor, and bios.

It it even possible?

Private Sub GetSerials()
Dim List, Msg, Object
On Local Error Resume Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_BaseBoard")
For Each Object In List
Msg = Msg & "Motherboard Serial Number: " & Object.SerialNumber & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_Processor")
For Each Object In List
Msg = Msg & "Processor Unique ID: " & Object.UniqueID & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_BIOS")
For Each Object In List
Msg = Msg & "BIOS Serial Number: " & Object.SerialNumber & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_LogicalDisk")
For Each Object In List
Msg = Msg & "Disk Serial Number: " & Object.VolumeSerialNumber & vbCrLf
Next

MsgBox Msg

End Sub


"John G." wrote:

Is there a envstring for the Environ() function that will return a unique
value, such as a serial # of the processor, Windows, Office, etc?

I want to setup some type of security should the XLS and not the XLT be
copied for use on another computer. I have no problem with the copying, it's
just that there will be CC info stored in the existing XLS file and I don't
want that to be distributed.
If I can check for two or three unique serials, I can have the routine clear
the existing data and reset the XLS to it's original delivered status. By
having more than one serial # to check, I can make sure the reset won't
happen should a minor hardware swap take place.

Sometime ago, I worked on a project in FoxPro where the code used a primary
harddrive serial # as a seed for an activation code. Was look for a similar
avenue if it's not too complicated.
Thx, JG


John G.[_2_]

Environmental Variables
 

Thx again for the reply...I'm not getting anything back MB#. Stepped
thru the function and the For...Next isn't grabbing anything. May be for the
same reason the code I found didn't find it either. JG

"Jacob Skaria" wrote:

To get serial number of mother board; try the below function..

Public Function MBSerialNumber() As String
Dim objs As Object, obj As Object, objWM As Object
Set objWM = GetObject("WinMgmts:")
Set objs = objWM.InstancesOf("Win32_BaseBoard")
For Each obj In objs
MBSerialNumber = "," & MBSerialNumber & obj.SerialNumber
Next
MBSerialNumber = Mid(MBSerialNumber, 2)
End Function

If this post helps click Yes
---------------
Jacob Skaria


"John G." wrote:

I found this code but it only seems to produce the disk partitiion ID's and
not motherboard, processor, and bios.

It it even possible?

Private Sub GetSerials()
Dim List, Msg, Object
On Local Error Resume Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_BaseBoard")
For Each Object In List
Msg = Msg & "Motherboard Serial Number: " & Object.SerialNumber & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_Processor")
For Each Object In List
Msg = Msg & "Processor Unique ID: " & Object.UniqueID & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_BIOS")
For Each Object In List
Msg = Msg & "BIOS Serial Number: " & Object.SerialNumber & vbCrLf
Next

Set List =
GetObject("winmgmts:{impersonationLevel=impersonat e}").InstancesOf("Win32_LogicalDisk")
For Each Object In List
Msg = Msg & "Disk Serial Number: " & Object.VolumeSerialNumber & vbCrLf
Next

MsgBox Msg

End Sub


"John G." wrote:

Is there a envstring for the Environ() function that will return a unique
value, such as a serial # of the processor, Windows, Office, etc?

I want to setup some type of security should the XLS and not the XLT be
copied for use on another computer. I have no problem with the copying, it's
just that there will be CC info stored in the existing XLS file and I don't
want that to be distributed.
If I can check for two or three unique serials, I can have the routine clear
the existing data and reset the XLS to it's original delivered status. By
having more than one serial # to check, I can make sure the reset won't
happen should a minor hardware swap take place.

Sometime ago, I worked on a project in FoxPro where the code used a primary
harddrive serial # as a seed for an activation code. Was look for a similar
avenue if it's not too complicated.
Thx, JG



All times are GMT +1. The time now is 11:40 PM.

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