new user
new user

Reputation: 1

Checking status of Bitlocker is return null

I created block of code for checking bitlocker is enable or not in machine following to this topic: Detect BitLocker programmatically from c# without admin I is working well almost machine, but from now there is a machine return null value:

IShellProperty prop = ShellObject.FromParsingName(rootDrive).Properties.GetProperty("System.Volume.BitLockerProtection");
int? bitLockerProtectionStatus = (prop as ShellProperty<int?>).Value; // bitLockerProtectionStatus return null

This machine already installed bitlocker. I've already checked with command "manage-bde -status C:" and return status "Fully Encrypted".

The above topic only mentioned If the value of this property is 1, 3, or 5, BitLocker is enabled on the drive. Any other value is considered off. How this value return null and where could i check the value of this ("System.Volume.BitLockerProtection") in machine?

Upvotes: 0

Views: 486

Answers (1)

PaulYBChiang
PaulYBChiang

Reputation: 61

My code to detect bitlocker drive:

if (!new DriveInfo(DriveName).IsReady)
{
    Process p = Process.Start(new ProcessStartInfo()
    {
        FileName = "cmd.exe",
        Arguments = " /C " + DriveName,
        Verb = "runas",
        UseShellExecute = false,
        RedirectStandardOutput = true,
        RedirectStandardError = true
    });
    string error = p.StandardError.ReadToEnd();
    string console = p.StandardOutput.ReadToEnd();
    bool IsBitLockerDrive = (error + console).Contains("BitLocker");//pw protected drive
}

Upvotes: 0

Related Questions