在本地系统中使用VB.NET中的WMI查询获取Bitlocker信息时拒绝访问
我正在开发一个VB.NET应用程序,从本地系统获取Bitelocker信息。下面是我的代码。当我以管理员权限运行时,这段代码可以完美地运行并返回结果。但它在没有管理员访问权限的情况下运行时出错在本地系统中使用VB.NET中的WMI查询获取Bitlocker信息时拒绝访问,vb.net,wmi,Vb.net,Wmi,我正在开发一个VB.NET应用程序,从本地系统获取Bitelocker信息。下面是我的代码。当我以管理员权限运行时,这段代码可以完美地运行并返回结果。但它在没有管理员访问权限的情况下运行时出错 Dim arEncryptionMethod = {"None", "AES 128 With Diffuser", "AES 256 With Diffuser", _ "AES 128", "AES 256"} Dim arProtectionStatus = {"Protection Off
Dim arEncryptionMethod = {"None", "AES 128 With Diffuser", "AES 256 With Diffuser", _
"AES 128", "AES 256"}
Dim arProtectionStatus = {"Protection Off", "Protection On", "Protection Unknown"}
Dim strComputer = "."
Dim colItems As New ManagementObjectSearcher("\\" & strComputer & _
"\root\CIMV2\Security\MicrosoftVolumeEncryption",
"Select * from Win32_EncryptableVolume " & "Where DriveLetter='C:'")
For Each objItem As ManagementObject In colItems.Get()
ListBox1.Items.Add("Volume:" & objItem("DriveLetter"))
ListBox1.Items.Add(" EncryptionMethod: " & arEncryptionMethod(objItem.InvokeMethod _
("GetEncryptionMethod", Nothing, Nothing)("EncryptionMethod")))
ListBox1.Items.Add(" ProtectionStatus: " & arProtectionStatus(objItem.InvokeMethod _
("GetProtectionStatus", Nothing, Nothing)("ProtectionStatus")))
Next
通过编辑应用程序下的
RequestedExecutionLevel
,为您的程序授予管理员权限。您需要显示解决方案下的所有文件,请查找app.manifest
更改默认值:
至
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
另一个注意事项是,当您打开此文件时,其中应该有注释,说明您可以将其更改为什么类型。通过编辑应用程序下的请求执行级别
为您的程序管理员授予特权。您需要显示解决方案下的所有文件,请查找app.manifest
更改默认值:
至
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
另一个注意事项是,当您打开此文件时,其中应该有注释,说明您可以将其更改为什么类型。您好,谢谢您的回复。我已经试过了,如果我们将级别更改为“requireAdministrator”,当我们运行应用程序时,它将要求管理员凭据在用户帐户有限的系统中执行。请让我知道有没有其他方法可以做到这一点。我怀疑这是因为Bitlocker更安全。我可以使用除“Win32_EncryptableVolume”之外的所有其他类。您好,谢谢您的回复。我已经试过了,如果我们将级别更改为“requireAdministrator”,当我们运行应用程序时,它将要求管理员凭据在用户帐户有限的系统中执行。请让我知道有没有其他方法可以做到这一点。我怀疑这是因为Bitlocker更安全。我可以使用除“Win32_EncryptableVolume”之外的所有其他类。