go: syscall: exec_windows.go: arguments should not be escaped to work with msiexec
Problem: When I try to run a command in Go on Windows using exec.Command() and then exec.Run(), the arguments are escaped using this logic: https://github.com/golang/go/blob/master/src/syscall/exec_windows.go#L26. That logic escapes the quotes around TARGETDIR=“%v” which need to be there. I currently am assigning to Cmd.SysProcAttr manually to get around the escaping.
- What version of Go are you using (
go version
)? Go 1.6.2 - What operating system and processor architecture are you using (
go env
)? Windows 10 Pro x64 - What did you do?
- The code is available here, but needs to be run on Windows: https://play.golang.org/p/aU1PlbNTqM
- Download any MSI. I used https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.2.6-signed.msi and renamed it to package.msi.
- You can run Error() and NoError() to see the difference
- What did you expect to see? I expect to see the MSI say: Completed the … Setup Wizard.
- What did you see instead? I see the Windows Installer help Windows and when I click it, I get: exit status 1639 which is: ERROR_INVALID_COMMAND_LINE 1639 Invalid command line argument. Consult the Windows Installer SDK for detailed command line help.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 5
- Comments: 34 (21 by maintainers)
Commits related to this issue
- Fixes #41 - Issue with blank spaces in path exec.Command() can't handle spaces, even when quoted. Command has to be modified using SysProcAttr. See also: https://github.com/golang/go/issues/15566 Pl... — committed to s-h-a-d-o-w/nvm-windows by s-h-a-d-o-w 6 years ago
- Fixes #41 - Issue with blank spaces in path exec.Command() can't handle spaces, even when quoted. Command has to be modified using SysProcAttr. See also: https://github.com/golang/go/issues/15566 Pl... — committed to s-h-a-d-o-w/nvm-windows by s-h-a-d-o-w 6 years ago
Probably is the same issue. Perhaps %windir%\system32\inetsrv\appcmd uses different command line parameters escaping rules.
Alex
I’m not sure trying to detect this is the correct way. I suggest to add (somewhere) a
CmdCommand()
function that does the escaping, and then specify in the documentation thatcmd
requires a non-standard escaping and thus point users toCmdCommand()