带有Powershell的MQ MFT

时间:2016-10-13 22:28:14

标签: ibm-mq websphere-mq-fte

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>

错误读取

  

无法运行程序createprocess error = 193 MoveFileToArchive.ps1不是有效的win32应用程序

我尝试使用powershell.exe添加powershell的路径,如此定义

<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>

这也不起作用。

1 个答案:

答案 0 :(得分:1)

从错误中可以看出,MFT代理正在使用var str = "aVal,bVal,cVal,dVal,eVal"; var rgx = 'bVal'; var x = 'replacement'; var res = str.replace(rgx, x); console.log(res); API来启动程序。 CreateProcess API只能运行可执行文件。您使用的CreateProcess脚本是不可执行的。因此错误。

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

尝试使用批处理文件说CreateProcess并在批处理文件中运行PowerShell脚本,如

ps.cmd

%1将成为PS脚本的参数。

Ant脚本也需要一点改变。

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

我确信您已将 <fte:presrc command="ps.cmd" successrc="0"> <fte:arg value="${base.file}"/> </fte:presrc> 属性设置为agent.properties中的合适值。

试一试。