{"action":"created","issue":{"url":"https://api.github.com/repos/mitchellh/packer/issues/2378","labels_url":"https://api.github.com/repos/mitchellh/packer/issues/2378/labels{/name}","comments_url":"https://api.github.com/repos/mitchellh/packer/issues/2378/comments","events_url":"https://api.github.com/repos/mitchellh/packer/issues/2378/events","html_url":"https://github.com/mitchellh/packer/issues/2378","id":92590370,"number":2378,"title":"Default Environment Properties like, PACKER_BUILDER_TYPE are not set in WindowsShell and PowerShell","user":{"login":"Skarlso","id":182850,"avatar_url":"https://avatars.githubusercontent.com/u/182850?v=3","gravatar_id":"","url":"https://api.github.com/users/Skarlso","html_url":"https://github.com/Skarlso","followers_url":"https://api.github.com/users/Skarlso/followers","following_url":"https://api.github.com/users/Skarlso/following{/other_user}","gists_url":"https://api.github.com/users/Skarlso/gists{/gist_id}","starred_url":"https://api.github.com/users/Skarlso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Skarlso/subscriptions","organizations_url":"https://api.github.com/users/Skarlso/orgs","repos_url":"https://api.github.com/users/Skarlso/repos","events_url":"https://api.github.com/users/Skarlso/events{/privacy}","received_events_url":"https://api.github.com/users/Skarlso/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mitchellh/packer/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/mitchellh/packer/labels/provisioner/winrm","name":"provisioner/winrm","color":"c7def8"},{"url":"https://api.github.com/repos/mitchellh/packer/labels/windows","name":"windows","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-02T09:13:17Z","updated_at":"2015-07-26T20:05:15Z","closed_at":null,"body":"Hi!\r\n\r\nI noticed something odd. When I'm using WindowsShell provisioner or PowerShell provisioner, the Environment values like PACKER_BUILDER_TYPE and such are not set. \r\n\r\nWhen I'm running something like this: \r\n```json\r\n  \"provisioners\": [\r\n    {\r\n      \"type\": \"shell\",\r\n      \"remote_path\": \"/tmp/script.bat\",\r\n      \"execute_command\": \"{{.Vars}} cmd /c C:/Windows/Temp/script.bat\",      \r\n      \"scripts\": [\r\n        \"./scripts/vm-guest-tools.bat\",\r\n        \"./scripts/puppet.bat\",\r\n        \"./scripts/vagrant-ssh.bat\",\r\n        \"./scripts/rsync.bat\",\r\n        \"./scripts/enable-rdp.bat\"\r\n      ]\r\n    }\r\n```\r\n\r\nvm-guest-tools will see the property fine. It runs a couple of setups based on builder type and that works.\r\n\r\nIf I use something like this: \r\n```json\r\n  \"provisioners\": [\r\n    {\r\n      \"type\": \"windows-shell\",\r\n      \"remote_path\": \"c:\\\\windows\\\\temp\\\\script.bat\",\r\n      \"execute_command\": \"{{.Vars}} cmd /c C:\\\\Windows\\\\Temp\\\\script.bat\",      \r\n      \"scripts\": [\r\n        \"./scripts/vm-guest-tools.bat\",\r\n        \"./scripts/puppet.bat\",\r\n        \"./scripts/vagrant-ssh.bat\",\r\n        \"./scripts/rsync.bat\",\r\n        \"./scripts/enable-rdp.bat\"\r\n      ]\r\n    }\r\n```\r\nOr, the / instead of \\\\, doesn't matter, vm-guest-tools will report PACKER_BUILDER_TYPE as an Empty String (\"\").\r\n\r\nI have no clue why. The code sets it the same way in both cases, using => \r\n```go\r\n\tenvVars := make([]string, len(p.config.Vars)+2)\r\n\tenvVars[0] = fmt.Sprintf(\"PACKER_BUILD_NAME='%s'\", p.config.PackerBuildName)\r\n\tenvVars[1] = fmt.Sprintf(\"PACKER_BUILDER_TYPE='%s'\", p.config.PackerBuilderType)\r\n```\r\nSo... yeah... that's it.\r\n\r\nAlso, once I try c:\\\\windows... it actually just hangs there. I'm guessing it tries to do some magic, but can't. \r\n\r\nCheers,\r\nGergely."},"comment":{"url":"https://api.github.com/repos/mitchellh/packer/issues/comments/125034103","html_url":"https://github.com/mitchellh/packer/issues/2378#issuecomment-125034103","issue_url":"https://api.github.com/repos/mitchellh/packer/issues/2378","id":125034103,"user":{"login":"markhuber","id":565388,"avatar_url":"https://avatars.githubusercontent.com/u/565388?v=3","gravatar_id":"","url":"https://api.github.com/users/markhuber","html_url":"https://github.com/markhuber","followers_url":"https://api.github.com/users/markhuber/followers","following_url":"https://api.github.com/users/markhuber/following{/other_user}","gists_url":"https://api.github.com/users/markhuber/gists{/gist_id}","starred_url":"https://api.github.com/users/markhuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markhuber/subscriptions","organizations_url":"https://api.github.com/users/markhuber/orgs","repos_url":"https://api.github.com/users/markhuber/repos","events_url":"https://api.github.com/users/markhuber/events{/privacy}","received_events_url":"https://api.github.com/users/markhuber/received_events","type":"User","site_admin":false},"created_at":"2015-07-26T20:05:14Z","updated_at":"2015-07-26T20:05:14Z","body":"I'm seeing this same behavior as well. I believe it only occurs when the elevated user/password is set. I'm not seeing it happen when those parameters are not set. @pecigonzalo that could help you narrow down the issue I hope, good luck. "}}