使用 Powershell 的 MQ MFT

MQ MFT With Powershell

IBM WS MQ7.5,windows MQMFT 代理,linux MQ 管理器。

我正在尝试 运行 在 MQ mft ant 脚本的 xml 中定义的 powershell 脚本。

我在 agent.properties 文件的 commandPath 中配置了 powershell 脚本的路径。

托管调用开始但失败

<fte:presrc command="C:\IBM\MFT\script\MoveFileToArchive.ps1" successrc="0">
               <fte:arg value="${base.file}"/>
            </fte:presrc>

错误显示为

cannot run program createprocess error=193 MoveFileToArchive.ps1 is not a valid win32 application

我尝试添加到 powershell 的路径 powershell.exe 定义如下

<fte:presrc command="C:\windows\system\windowspowershell\v.1.0\powershell.exe C:\IBM\MFT\script\MoveFileToArchive.ps1" successrc="0">
               <fte:arg value="${base.file}"/>
            </fte:presrc>

这也不行。

从报错可以看出,MFT代理正在使用CreateProcessAPI启动一个程序。 CreateProcess API 可以 运行 只有可执行文件。您正在使用的 Powershell 脚本是不可执行的。因此错误。

如果您希望能够使用关联的应用程序打开任何文件,则需要 ShellExecute 而不是 CreateProcess。但这不在你的控制之下。所以需要寻找替代品吗?

尝试使用批处理文件 ps.cmd 并在批处理文件中 运行 PowerShell 脚本

Powershell -executionpolicy bypass -File C:\IBM\MFT\script\MoveFileToArchive.ps1 %1

其中 %1 是 PS 脚本的参数。

Ant 脚本也需要一点改动。

    <fte:presrc command="ps.cmd" successrc="0">
       <fte:arg value="${base.file}"/>
    </fte:presrc>       

我确定您已经在 agent.properties.

中将 commandPath 属性 设置为合适的值

试一试。