joefitzgerald/packer-windows — pull request #8 by dylanmei (2013-11-14 13:08:49+00:00)
Title: Ensure TEMP and USERPROFILE variables are always available

By enabling "PermitUserEnvironment" in the sshd settings we can setup environment variables that are available on every ssh command. This is neat because 1. TEMP can now be defined once and all provisioners can use it and 2. provisioners can append their own variables to ~/.ssh/environment.

USERPROFILE has always been empty because windows doesn't define it until the user interactively logs in. This is a problem because 1. systems like Chocolatey depend on it and 2. when Vagrant does finally log in interactively, Windows creates a user home directory of C:\Users\Vagrant.MACHINE_NAME because C:\Users\Vagrant has already created by packer-windows.

I first noticed this was a problem when researching #6. The change here is to run the Autounattend AutoLogon as vagrant rather than admin, which then creates the USERPROFILE we expect. From my tests everything runs as normal and there is no need to run as admin.