From 71bfe7c8843d34c4a22ea47d1cdec0d57ebc0174 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 28 Apr 2017 15:05:08 -0700 Subject: [PATCH] Fix shell provisioner to execute batch files correctly Call cmd.exe explicitly when running batch files to easily manage special characters that may be within the path. Fixes #8535 --- plugins/provisioners/shell/provisioner.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index f50507549..48089dc18 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -191,8 +191,11 @@ module VagrantPlugins shell_args += " -OutputFormat Text" if config.powershell_args !~ /[-\/]OutputFormat/i command = "\"#{exec_path}\"#{args}" - command = "powershell #{shell_args.to_s} -file #{command}" if - File.extname(exec_path).downcase == '.ps1' + if File.extname(exec_path).downcase == ".ps1" + command = "powershell #{shell_args.to_s} -file #{command}" + else + command = "cmd /q /c #{command}" + end # Append the environment if !env.empty?