我知道这是一个非常老的问题。 然而,当我面临一个类似问题时,谷歌还是导致我出现这一问题。 我采取了以下行动来解决我的问题。
。
<AutoLogon>
<Password>
<Value>NewUser sPassword</Value>
<PlainText>true</PlainText>
</Password>
<Username>NewUser sName</Username>
<Enabled>true</Enabled>
<LogonCount>999</LogonCount>
</AutoLogon>
The resulting file should look like the snippet below。 I have removed the parts not necessary for this answer。
<?xml version="1。0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<!-- snip -->
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas。microsoft。com/WMIConfig/2002/State" xmlns:xsi="http://www。w3。org/2001/XMLSchema-instance">
<!-- snip -->
<AutoLogon>
<Password>
<Value>NewUser sPassword</Value>
<PlainText>true</PlainText>
</Password>
<Username>NewUser sName</Username>
<Enabled>true</Enabled>
<LogonCount>999</LogonCount>
</AutoLogon>
</component>
</settings>
<!-- snip -->
</unattend>
Next we edit the EC2ConfigService settings。
- In the file
"C:Program FilesAmazonEc2ConfigServiceSettingsBundleConfig。xml"
, ensure the value for SetPasswordAfterSysprep
is Yes
。
- In the file,
"C:Program FilesAmazonEc2ConfigServiceSettingsconfig。xml"
, ensure the state
node has the value Enabled
for the plugin Ec2SetPassword
。
- In the file,
"C:Program FilesAmazonEc2ConfigServiceSettingsconfig。xml"
, ensure the value for RemoveCredentialsfromSysprepOnStartup
is false
。
You are already launching an exe on logon。 Using the same mechanism, also launch a script that will delete the AutoLogonCount
setting from the registry。 This step is important, else after 999 (as per the example mentioned above) logins, the autologon will stop。
。
powershell。exe -command { Remove-ItemProperty -Path "HKLM:SoftwareMicrosoftWindows NTCurrentVersionwinlogon" -Name AutoLogonCount -Force -ErrorAction 0 }
- Now we can start Sysprep。 Either use the UI or the following command。
。
%ProgramFiles%AmazonEc2ConfigServiceec2config。exe -sysprep
Any instance launched using an AMI created from the above instance, retains the auto-logon behaviour indefinitely。