Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking Bitlocker Encryption Status in Visual Basic

I am trying to build an application in Visual Studio via Visual Basic and am pulling information of the current machine. Basically, what I want to do is pull the encryption status of Bitlocker in Visual Basic that outputs if the C: Drive is Bitlocked or is not Bitlocked.

I have looked around for something that completes this on the internet, but everything I see has something to do with WMI. It also appears that WMI needs to be installed on each machine you will be utilizing it on. I just want to be able to go to machine after machine run the file and have all my information outputted in the form. My code for pulling everything right now is as follows:

Public Class ComputerInformation
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        TextBoxComputerName.Text = Environment.MachineName
        TextBoxOSVersion.Text = System.Environment.OSVersion.ToString
        TextBoxOSFullName.Text = My.Computer.Info.OSFullName
        TextBoxCurrentUser.Text = System.Environment.UserName
        TextBox64Bit.Text = System.Environment.Is64BitOperatingSystem
        TextBoxSystemDirectory.Text = System.Environment.SystemDirectory
        TextBoxDomain.Text = System.Environment.UserDomainName
        ' CHECK BITLOCKER STATUS HERE.
    End Sub
End Class

Some help and maybe an explanation would be greatly appreciated! Thank you!

like image 785
Aaron Brewer Avatar asked Jan 30 '14 17:01

Aaron Brewer


People also ask

How do I check my BitLocker encryption status?

Checking BitLocker Status (Command Line) Press and hold the Windows button on the keyboard and R, type "cmd" and press Enter. Right-click Command Prompt and select "Run as Administrator." In command prompt, type "manage-bde -status" and press Enter. View the status of BitLocker on the drives in the computer.

How do I know if BitLocker is enabled?

Or, select the Start button, and then under Windows System, select Control Panel. In Control Panel, select System and Security, and then under BitLocker Drive Encryption, select Manage BitLocker. Note: You'll only see this option if BitLocker is available for your device.

How do I view BitLocker Decryption progress?

If you want to check out the used algorithm or if BitLocker is currently encrypting or decrypting your files, you need a Command Prompt line. In the Start menu search bar, search for command prompt and select Run as administrator. Type manage-bde -status to check the status for all drives. Press Enter.


2 Answers

Yes, you query this by using the Win32_EncryptableVolume WMI class. The ProtectionStatus property tells you whether encryption is turned on. WMI does not have to be installed. However, the Win32_EncryptableVolume class will only be available if Bitlocker is present on the machine.

To get started, first download the WMI Code Creator utility. It lets you play with WMI queries and will automatically generate the VB.NET code you need and test it. In the menu, use Code Language and pick "Visual Basic.NET". Select Win32_EncyptableVolume from the Classes combobox and select the ProtectionStatus property. Click "Execute Code" to test it. Copy/paste the generated source code into your program. Also check the code on a machine that doesn't have Bitlocker available, you'll need to catch the exception you get so you know Bitlocker isn't present at all.

like image 197
Hans Passant Avatar answered Oct 30 '22 15:10

Hans Passant


As Hans Passant stated above, use the WMI Code Creator utility.
You can select Win32_EncryptableVolume from the classes combobox when you chose the namespace root\CIMV2\Security\MicrosoftVolumeEncryption.

You could use something like this to determine if BitLocker is active/available:

IShellProperty prop = ShellObject.FromParsingName("C:").Properties.GetProperty("System.Volume.BitLockerProtection");
int? bitLockerProtectionStatus = (prop as ShellProperty<int?>).Value;

if (bitLockerProtectionStatus.HasValue && (bitLockerProtectionStatus == 1 || bitLockerProtectionStatus == 3 || bitLockerProtectionStatus == 5))
   Console.WriteLine("ON");
else
   Console.WriteLine("OFF");

Note that this is C# code, but easily convertible.

like image 28
kabinx Avatar answered Oct 30 '22 16:10

kabinx