VB.Net and BitLocker Drive Encryption Status

~OSD~ 2,131 Reputation points


Is it possible to get the status of the Bit Locker Drive for the "C:\" volume using VB.Net?

Currently I am able to get the status using manage-bde -status and following PowerShell as well:
$bitlockerVolume = Get-BitLockerVolume -MountPoint "C:"
$statusBitlocker = $bitlockerVolume.ProtectionStatus
if ($statusBitlocker -eq "On")
With VB.Net, I would like to test it when form1 loads. If C drive is encrypted show the dialog box 1 else show form2, possible in vb.net?

An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,605 questions
0 comments No comments
{count} votes

Accepted answer
  1. ~OSD~ 2,131 Reputation points


    Atleast some progress, now I am able to have some results with help of following code:
    But I would like to check ONLY if C:\ drive is encrypted then show a message box. Otherwise /IF not encrypted, show form2.

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
                Dim searcher As New ManagementObjectSearcher("root\cimv2\Security\MicrosoftVolumeEncryption", "SELECT * FROM Win32_EncryptableVolume")
                For Each queryObj As ManagementObject In searcher.Get()
                    Dim drvLtr = "C:"
                    Dim prtStatus = "1"
                    If queryObj("DriveLetter").ToString.ToUpper.Contains(drvLtr.ToUpper) AndAlso queryObj("ProtectionStatus").ToString.ToUpper.Contains(prtStatus.ToUpper) Then
                        MessageBox.Show(queryObj("DriveLetter").ToString & "Drive is Encrypted.") 'Concludes C:\ is encrypted
                    Else 'Otherwise assume C:\ is not encrypted.
                        MessageBox.Show(queryObj("DriveLetter").ToString & "Drive is NOT Accessible.")
                    End If
            Catch err As ManagementException
                Me.Text = "An error occurred while querying for WMI data: " & err.Message
            End Try
        End Sub

    But it seems like all drives are being evaluated and false results generated in messagebox.
    Any thought to limit it to scan for C:\ drive ONLY?

    Code Credits: how-to-get-the-result-of-a-getproperties-method-of-a-wmi-class-in-vbnet-using

2 additional answers

Sort by: Most helpful
  1. Castorix31 82,116 Reputation points

    You can use WMI
    Win32_EncryptableVolume class

    1 person found this answer helpful.
    0 comments No comments

  2. ~OSD~ 2,131 Reputation points

    Which NameSpace?


    Win32_EncryptableVolume isn't available?

    Someone have an example? [2]: /api/attachments/67385-image.png?platform=QnA