View Single Post
 
Old 10-16-2018, 08:23 PM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 591
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

This macro will obtain the Hard Drive serial number :

Code:
Option Explicit

Sub GetPhysicalSerial()
 
Dim obj As Object
Dim WMI As Object
 
Set WMI = GetObject("WinMgmts:")
 
For Each obj In WMI.InstancesOf("Win32_PhysicalMedia")
MsgBox "SN: " & obj.SerialNumber
Next
 
End Sub
This code is for a Visual Basic Script file. It obtains the machine serial number.

Code:
 strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystemProduct") 
For Each objItem in colItems 
    msgbox "This Device: " & objItem.IdentifyingNumber, vbOkayOnly, "Serial Number"
Next
Paste the code into NOTEPAD, then save it as Serial Number.vbs

If you are sending your project to a customer, you can send the customer both of these files first. Request the customer run the files and send you the information that is obtained. Then you can utilize that information in your macro code to verify it is running on the correct machine. You would do this the same way as you would be checking for a password.

This macro will time limit the use of the workbook, advising the user how many days they have left before it expires.

Code:
Option Explicit

Sub EndSplash()
    Dim exdate As Date
    UserForm1.Hide
    exdate = "11/27/2018"      '<---- Uncomment and add expire date !!!!!!!!!!!!!!!
    If Date > exdate Then
        MsgBox ("End of your trail period! Contact to Theikdi Maung")
        ActiveWorkbook.Close
    End If
    MsgBox ("You have " & exdate - Date & " Days left")
End Sub
The attached file is the sample workbook for you to review.
Attached Files
File Type: xlsm Time Bomb.xlsm (23.8 KB, 15 views)
Reply With Quote