如何使用脚本在windows中更改Bitlocker密码?

2024-06-10 07:41:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一个脚本来更改windows中的bitlocker密码。在

我发现可以执行“manage-bde-changepassword C:”来更改bitlocker的密码。如果在命令提示符下运行,它将要求用户输入密码并确认密码。手动操作效果很好。 如何通过python子进程模块或vb脚本或使用Powershell来实现这一点?在

我试过遵循代码,但它不起作用

import subprocess
p =subprocess.Popen("manage-bde -changepassword C:", shell = True,stdin=subprocess.PIPE, stdout=subprocess.PIPE)
p.stdin.write("Passw0rd")
stdout, stderr = p.communicate("Passw0rd")
print stdout

错误:

^{pr2}$

但还没试过vb下面的脚本

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("manage-bde.exe -changepassword C:" ,0,True)
WshShell.SendKeys "P@ssw0rd"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "P@ssw0rd"
WshShell.SendKeys "{ENTER}"

Tags: 脚本true密码managestdinstdoutsubprocessvb