如何阻止Golang在执行Windows命令时用反斜杠替换双引号?

如何阻止Golang在执行Windows命令时用反斜杠替换双引号?,windows,go,cmd,double-quotes,backslash,Windows,Go,Cmd,Double Quotes,Backslash,我正在用Golang编写一个程序,它将使用Mozilla的Thunderbird电子邮件客户端发送电子邮件。应执行的Windows命令是: start "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" -compose "to='CloudCoin@Protonmail.com',subject='Subject1',body='Hello'" -offline 我的Go代码如下所示(命令如下所示): 但我有一个错

我正在用Golang编写一个程序,它将使用Mozilla的Thunderbird电子邮件客户端发送电子邮件。应执行的Windows命令是:

 start "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" -compose "to='CloudCoin@Protonmail.com',subject='Subject1',body='Hello'" -offline
我的Go代码如下所示(命令如下所示):

但我有一个错误:

Windows cannot find '\\'. Make sure you typed the name correctly, and then try again. 
如果我将代码更改为此(移动单词start):

然后我得到另一个错误:

Windows cannot find 'Files'. Make sure you typed the name correctly, and then try again. 

似乎不是尝试启动“”而是尝试启动\\。如何保留双引号?

您的问题可能是,传递给
exec.Command
的每个单独的字符串都作为单个参数传递给
cmd.exe
,该参数可能也不会拆分给定的字符串,因此您必须自己执行

看看争论在哪里被分开。您应该能够省去“out”,因为您可以手动拆分它,或者为它编写程序,或者使用执行拆分的解释器运行它

func do() {
    args := []string{
        "/C",
        "start",
        "",
        `C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe`,
        "-compose",
        "to=" + toAddress + ",subject=Subject1,body=Hello",
        "-offline",
    }
    cmd := exec.Command("cmd.exe", args...)
}

我们可以看看你是如何声明“命令”的吗?完全错误,因为没有必要引用。仅此而已。
Windows cannot find 'Files'. Make sure you typed the name correctly, and then try again. 
func do() {
    args := []string{
        "/C",
        "start",
        "",
        `C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe`,
        "-compose",
        "to=" + toAddress + ",subject=Subject1,body=Hello",
        "-offline",
    }
    cmd := exec.Command("cmd.exe", args...)
}