![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Looking for an err message I am writting script to determine if the Trusted Platform Module (TPM) is turned on and active. If the TPM is turned on in the BIOS I have no problems checking it's status. My problem is when it is turned off, I do not get any error messages. Here is the code; Set objWMIService = GetObject("WinMgmts: {impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" _ & "." & "\root\CIMV2\Security\MicrosoftTpm") '<-- all one line Set objItems = objWMIService.InstancesOf("Win32_Tpm") For Each objItem In objItems rvaluea = objItem.IsEnabled(A) rvalueb = objItem.IsActivated(B) rvaluec = objItem.IsOwned(C) If A Then WScript.Echo "TPM Is Enabled: " & A Else WScript.Echo "TPM Is Enabled: " & A End If If B Then WScript.Echo "TPM Is Activated: " & B Else WScript.Echo "TPM Is Activated: " & B End If If C Then WScript.Echo "TPM Is Owned: " & C Else WScript.Echo "TPM Is Owned: " & C End If Next Any ideas on how to tell if there is no responce from the TPM? I tried this Set objWMIService = GetObject("WinMgmts: {impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" _ & "." & "\root\CIMV2\Security\MicrosoftTpm") '<-- all one line Set objItems = objWMIService.InstancesOf("Win32_Tpm") If Err.Number <> 0 Then WScript.Echo "Trusted Platform Module may be turned off" End If But I get err 0 regardless of the state of the device. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Looking for an err message "OldDog" <mikef2691@xxxxxx> wrote in message news:1e15be35-8822-4167-883a-7d7193ba24c0@xxxxxx Quote: >I am writting script to determine if the Trusted Platform Module (TPM) > is turned on and active. > > If the TPM is turned on in the BIOS I have no problems checking it's > status. > My problem is when it is turned off, I do not get any error messages. > > Here is the code; > > Set objWMIService = GetObject("WinMgmts: > {impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" _ > & "." & "\root\CIMV2\Security\MicrosoftTpm") '<-- all one line > Set objItems = objWMIService.InstancesOf("Win32_Tpm") > > For Each objItem In objItems > > rvaluea = objItem.IsEnabled(A) > rvalueb = objItem.IsActivated(B) > rvaluec = objItem.IsOwned(C) > If A Then > WScript.Echo "TPM Is Enabled: " & A > Else > WScript.Echo "TPM Is Enabled: " & A > End If > > If B Then > WScript.Echo "TPM Is Activated: " & B > Else > WScript.Echo "TPM Is Activated: " & B > > End If > > If C Then > WScript.Echo "TPM Is Owned: " & C > Else > WScript.Echo "TPM Is Owned: " & C > > End If > Next > > Any ideas on how to tell if there is no responce from the TPM? > > I tried this > > Set objWMIService = GetObject("WinMgmts: > {impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" _ > & "." & "\root\CIMV2\Security\MicrosoftTpm") '<-- all one line > Set objItems = objWMIService.InstancesOf("Win32_Tpm") > > If Err.Number <> 0 Then > WScript.Echo "Trusted Platform Module may be turned off" > End If > > But I get err 0 regardless of the state of the device. and C are never defined or given a value. If the rest of the code is OK (I cannot tell), then this might work: ========= For Each objItem In objItems rvaluea = objItem.IsEnabled rvalueb = objItem.IsActivated rvaluec = objItem.IsOwned If rvaluea Then WScript.Echo "TPM Is Enabled" Else WScript.Echo "TPM Is Disabled" End If If rvalueb Then WScript.Echo "TPM Is Activated" Else WScript.Echo "TPM Is Not Activated" End If If rvaluec Then WScript.Echo "TPM Is Owned" Else WScript.Echo "TPM Is Not Owned" End If Next ====== I would recommend using Option Explicit and not using "On Error Resume Next". For example, I would use the following at the beginning of the script: ========== Option Explicit Dim objWMIService, objItems, objItem Dim rvaluea, rvalueb, rvaluec ========= Possibly if TPM is turned off, there are no objects in the collection objItems. You can detect this because the For Each loop will just skip and none of the statements in the loop will run. There will not necessarily be an error. You might want to use code similar to: ====== Dim blnOn blnOn = False For Each objItem In objItems rvaluea = objItem.IsEnabled rvalueb = objItem.IsActivated rvaluec = objItem.IsOwned blnOn = True If (rvaluea = True) Then WScript.Echo "TPM Is Enabled" Else WScript.Echo "TPM Is Disabled" End If If (rvalueb = True) Then WScript.Echo "TPM Is Activated" Else WScript.Echo "TPM Is Not Activated" End If If (rvaluec = True) Then WScript.Echo "TPM Is Owned" Else WScript.Echo "TPM Is Not Owned" End If Next If (blnOn = False) Then Wscript.Echo "TPM is turned off in BIOS" End If -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| new message window uploading photos error message | Live Mail | |||
| Email message attachments to a received windows mail message | Vista mail | |||
| Retrieving IMAP message stalls when message contains large attachment. | Vista mail | |||
| Deleting a message in an open window opens the next message in Inb | Vista mail | |||
| delete message returns me to previous message in the inbox | Vista mail | |||