如何以编程方式手动更改 modern.ie Windows 10 个虚拟机 (VM) 的默认管理员用户名和密码 and/or?

How to change default admin user name and password of a modern.ie Windows 10 virtual machine (VM) manually and/or programmatically?

意图

我想使用从 Microsoft modern.ie website with Vagrant. Although Microsoft provides a download option which is prepared for Vagrant (s. picture 01) it actually can't be used out of the box and needs some further configuration (e.g. as described here 下载的 Windows 10 虚拟机 (VM)。需要配置的一件事是用于引导的用户和密码。机器默认使用管理员用户 IEUser 和密码 Passw0rd! 启动。我想知道如何以两种不同的方式完成 user/password 的更改 - 手动(s. 问题 1)和编程(s. 问题 2)

图片01:

问题 1

我需要通过 Windows GUI 执行哪些详细步骤才能“真正”将管理员用户 IEUser/ Passw0rd! 的名称和密码更改为例如vagrant/vagrant?

注意:我已经尝试过明显的方法

  1. 用户帐户 --> 更改您的帐户名称 --> vagrant
  2. 用户帐户 --> 在 PC 设置中更改我的帐户 --> 登录选项 --> Password/Change --> 当前密码 => Passw0rd! --> 新密码=> vagrant ...等等
  3. 我最终使用 IEUser 和错误的密码启动
  4. 我想这与我未能通过 GUI 更改的配置文件有某种关系(参见图片 02

图片02:

问题 2

如何从命令行 (cmd) 更改管理员用户及其密码 (IEUser / Passw0rd!)?这样做的目的是拥有一个可以调用的脚本,例如来自 Vagrantfile 在 vagrant up-time.

我尝试了以下我发现的 PowerShell 命令 here 但它们对我不起作用(可能是因为它们适用于 Windows Server 2012 R2(?)):

$admin=[adsi]"WinNT://./Administrator,user"
$admin.psbase.rename("vagrant")
$admin.SetPassword("vagrant")
$admin.UserFlags.value = $admin.UserFlags.value -bor 0x10000
$admin.CommitChanges()

好的,我正在 运行ning build 1607,显然 稍微 与您使用的不同。但是您在 "Question 1" 中描述的操作(针对内部版本 1607 进行了调整)会更改用户密码,但不会更改自动登录密码。您在 "Question 2".

中发布的代码也是如此

Vagrant 设置似乎可以控制 Vagrant 通过网络连接到 VM 的方式。我不认为它们会影响 VM 本身。

有说明here (or Google "windows 10 automatic logon") for configuring/reconfiguring automatic logon, either via the GUI or via the registry. The registry method is easy to program in whatever language you prefer, and the registry keys are documented on Technet(或搜索"AutoAdminLogon")。

GUI 方法的快速总结:打开“开始”菜单或命令 window 和 运行 netplwiz。取消勾选 "Users must enter a user name and password to use this computer",或者如果它已经取消勾选,勾选它然后取消勾选。然后按应用,将出现一个对话框,询问要使用的凭据。

注册表方法的快速摘要:创建或设置各种 REG_SZ 值,如以下注册表项所述:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
  • AutoAdminLogon - 设置为“1”启用自动登录(注意这是一个字符串值)
  • DefaultDomainName - 计算机名称
  • DefaultUserName - 要登录的用户帐户
  • DefaultPassword - 用户帐户的密码

为了完整起见,另请参阅 MSDN 上的 Protecting the Automatic Logon Password。在这种情况下,无需加密密码。但是,如果 VM 附带加密的自动登录密码,您可能需要在添加明文密码之前删除加密密码。