Public Sub SetTPM()
Dim scope As ManagementScope = New ManagementScope("\\.\root\CIMV2\Security\MicrosoftTpm")
Dim query As SelectQuery = New SelectQuery("Win32_Tpm")
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(scope, query)
Dim mo As ManagementObject
For Each mo In searcher.Get()
Dim inParams As ManagementBaseObject = mo.GetMethodParameters("SetPhysicalPresenceRequest")
inParams("Request") = 10
Dim RC1 As ManagementBaseObject = mo.InvokeMethod("SetPhysicalPresenceRequest", inParams, Nothing)
If RC1("returnValue") <> 0 Then
MsgBox("Error setPhysicalPresenceRequest")
Else
MsgBox("SetPPR exited with code: " & RC1("returnValue"))
Dim objGetPPT As ManagementBaseObject = mo.InvokeMethod("GetPhysicalPresenceTransition", Nothing, Nothing)
Dim GetPPT As String = objGetPPT("Transition")
MsgBox(GetPPT)
Select Case GetPPT
Case 0
MsgBox("No user action is needed to perform a TPM physical presence operation.")
Case 1
MsgBox("To perform a TPM physical presence operation, the user must shutdown the computer and then turn it back on by using the power button. The user must be physically present at the computer to accept or reject the change when prompted by the BIOS.")
Case 2
MsgBox("To perform a TPM physical presence operation, the user must restart the computer by using a warm reboot. The user must be physically present at the computer to accept or reject the change when prompted by the BIOS.")
Case 3
MsgBox("The required user action is unknown.")
End Select
End If
Next
End Sub