在我的C#代码中,我能够通过编程方式锁定Windows用户会话(与Windows + L相同)。
由于应用程序仍在运行,是否有任何方法可以从C#程序解锁会话? 用户凭据已知。 该应用程序正在运行Windows 7上。
在我的C#代码中,我能够通过编程方式锁定Windows用户会话(与Windows + L相同)。
由于应用程序仍在运行,是否有任何方法可以从C#程序解锁会话? 用户凭据已知。 该应用程序正在运行Windows 7上。
var path = new ManagementPath();
path.NamespacePath = "\\ROOT\\CIMV2\\Security\\MicrosoftVolumeEncryption"; path.ClassName = "Win32_EncryptableVolume";
var scope = new ManagementScope(path, new ConnectionOptions() { Impersonation = ImpersonationLevel.Impersonate });
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[] { "here your pwd" });
Console.WriteLine("unlock done.");
}
}
注意:只有在以管理员身份运行Visual Studio时才有效。
不,根据设计,无法这样做。您的情况是什么,为什么需要锁定/解锁工作站?
当然你无法解锁它。解锁一个会话需要用户亲自在现场输入他们的帐户凭据。即使使用保存的凭据,允许软件这样做也将成为许多使用工作站锁定的其他情况的安全问题。