我正在用 Golang 编写一个程序,它将使用 Mozilla 的 Thunderbird 电子邮件客户端发送电子邮件。应执行的 Windows 命令是:
start "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" -compose "to='CloudCoin@Protonmail.com',subject='Subject1',body='Hello'" -offline
我的 Go 代码如下所示(命令是上面列出的命令):
var command string
command = `start "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"`
command += ` -compose "to='` + toAddress + `',`
command += `subject='Subject1',`
command += `body='Hello'"`
command += ` -offline`
cmd := exec.Command("cmd.exe", "/C", command)
但我收到一个错误:
Windows cannot find '\\'. Make sure you typed the name correctly, and then try again.
如果我将代码更改为这样(移动单词 start):
var command string
command = ` "" "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"`
command += ` -compose "to='` + toAddress + `',`
command += `subject='Subject1',`
command += `body='Hello'"`
command += ` -offline`
fmt.Println("Command: " + command)
cmd := exec.Command("cmd.exe", "/C", "start", command)
然后我得到另一个错误:
Windows cannot find 'Files'. Make sure you typed the name correctly, and then try again.
似乎不是尝试启动“”,而是尝试启动 \\。如何保留双引号?
哔哔one
相关分类