自动解锁Bitlocker加密硬盘

您所在的位置:网站首页 硬盘加密后如何解密码 自动解锁Bitlocker加密硬盘

自动解锁Bitlocker加密硬盘

2023-11-08 03:14| 来源: 网络整理| 查看: 265

自动解锁Bitlocker加密硬盘有两种方式,一种是将系统盘也加密,然后数据盘启动自动解锁。但是系统盘加密会降低系统运行速度,还是比较明显的。

第二种方式就是编写程序,开机后启动程序或者开机自动运行,解锁数据盘。参考:https://social.msdn.microsoft.com/Forums/vstudio/en-US/26c44d82-7aa3-4d18-a963-b86eb617a609/unlock-bit-locker-programmatically?forum=csharpgeneral。使用Visual studio新建一个c#的控制台项目。

 因为ManagementScope需要管理员权限,所以程序启动时,还要自动要求“管理员”权限。

using System; using System.Management; namespace unlockbitlocker { class Program { static void Main(string[] args) { string programStartLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; Console.WriteLine(programStartLocation); var path = new ManagementPath(); path.NamespacePath = "\\ROOT\\CIMV2\\Security\\MicrosoftVolumeEncryption"; path.ClassName = "Win32_EncryptableVolume"; var scope = new ManagementScope(path, new ConnectionOptions() { Impersonation = ImpersonationLevel.Impersonate }); scope.Options.EnablePrivileges = true; //enables required privileges var management = new ManagementClass(scope, path, new ObjectGetOptions()); foreach (ManagementObject vol in management.GetInstances()) { Console.WriteLine("----" + vol["DriveLetter"]); switch ((uint)vol["ProtectionStatus"]) { case 0: Console.WriteLine("not protected by bitlocker"); break; case 1: Console.WriteLine("unlocked"); break; case 2: Console.WriteLine("locked"); break; } if ((uint)vol["ProtectionStatus"] == 2) { Console.WriteLine("unlock this driver ..."); vol.InvokeMethod("UnlockWithPassphrase", new object[] { "Bitlocker解锁密码" }); Console.WriteLine("unlock done."); } } } } }

我们需要修改项目Properties文件中app.manifest文件,app.manifest文件默认是不存在的,需要通过以下操作来自动添加该文件。

(1)进入菜单项目-->XX属性。

(2)选择“安全性”栏。

(3)将“启用ClickOnce安全设置”勾选上。

 

  这样在Properties目录下就自动生成了app.manifest文件。打开该文件,将trustInfo/security/requestedPrivileges节点的requestedExecutionLevel的level的值修改为requireAdministrator即可。

 

 然后,回到项目属性安全性项目,将“启用ClickOnce安全设置”取消勾选。 最后重新编译程序就可以了,程序在\bin\Release目录下,双击,提示确认管理员权限运行,点是即可。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3