I have this command, which works when running in command line directly.
import "os/exec"
...
out, err := exec.Command("cmd", "/C", `%windir%\system32\inetsrv\appcmd list APP /site.name:"My website" /text:[path='/'].physicalPath`).Output()
When I run it via Go app, it throws exit status 3222072890 with this error message:
Failed to process input: Invalid XML input - please make sure that your XML is well-formed and follows the required format (HRESULT=c00cee3a).
I've already tried to change slashes, use various quotation marks, but still does not work.
I use IIS 8.5 on Windows Server 2012 R2.
It seems that command is corrupted before execution. Is there any way how to see the output command?
It seems to be a bug in golang library - related to a Golang Github issue #15566.
Issue is caused by quotation marks in /site.name argument ("My website") which are escaped, but should not be.
Solution for this time is this:
import "os/exec"
import "syscall"
...
cmd := exec.Command(`cmd`)
cmd.SysProcAttr = &syscall.SysProcAttr{
CmdLine: `/C %windir%\system32\inetsrv\appcmd list APP /site.name:"My website" /text:[path='/'].physicalPath`,
}
out, err := cmd.Output()
For more information see: http://www.josephspurrier.com/prevent-escaping-exec-command-arguments-in-go/ and exec with double quoted argument
I just deleted all carriage returns in xml
and removed Tag .
And
appcmd add apppool /in < C:\Installs\AppPool.xml
worked for me.