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
This commit is contained in:
Chris Roberts 2017-04-28 15:05:08 -07:00
parent a018eec3e7
commit 71bfe7c884
1 changed files with 5 additions and 2 deletions

View File

@ -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?