From 08359e409a0df8c3060dd56cfb1d0e4b5740f659 Mon Sep 17 00:00:00 2001 From: Gonzalo Peci Date: Wed, 19 Aug 2015 16:09:43 +1200 Subject: [PATCH] Revert the shutdown command with new parameters as this will return proper exit codes. This will work in the same way as restart-computer -force when using ```shutdown /r /f /t 0```. Note:The WinRM library does not return the exit code currently, this will be implemented on https://github.com/masterzen/winrm/pull/26 --- provisioner/windows-restart/provisioner.go | 2 +- provisioner/windows-restart/provisioner_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/provisioner/windows-restart/provisioner.go b/provisioner/windows-restart/provisioner.go index 26736344e..c5a683b73 100644 --- a/provisioner/windows-restart/provisioner.go +++ b/provisioner/windows-restart/provisioner.go @@ -13,7 +13,7 @@ import ( "github.com/mitchellh/packer/template/interpolate" ) -var DefaultRestartCommand = "powershell \"& {Restart-Computer -force }\"" +var DefaultRestartCommand = "shutdown /r /f /t 0 /c \"packer restart\"" var DefaultRestartCheckCommand = winrm.Powershell(`echo "${env:COMPUTERNAME} restarted."`) var retryableSleep = 5 * time.Second var TryCheckReboot = "shutdown.exe -f -r -t 60" diff --git a/provisioner/windows-restart/provisioner_test.go b/provisioner/windows-restart/provisioner_test.go index 247452c22..7a38e1579 100644 --- a/provisioner/windows-restart/provisioner_test.go +++ b/provisioner/windows-restart/provisioner_test.go @@ -35,7 +35,7 @@ func TestProvisionerPrepare_Defaults(t *testing.T) { t.Errorf("unexpected remote path: %s", p.config.RestartTimeout) } - if p.config.RestartCommand != "powershell \"& {Restart-Computer -force }\"" { + if p.config.RestartCommand != "shutdown /r /f /t 0 /c \"packer restart\"" { t.Errorf("unexpected remote path: %s", p.config.RestartCommand) } }