IBM WS MQ7.5, windows MQMFT agent, linux MQ manager.
I am trying to run a powershell script as defined in the xml of a MQ mft ant script.
I configured the path to the powershell scripts in commandPath of the agent.properties files.
The managed call starts but fails
<fte:presrc command="C:\IBM\MFT\script\MoveFileToArchive.ps1" successrc="0">
<fte:arg value="${base.file}"/>
</fte:presrc>
The error reads
cannot run program createprocess error=193 MoveFileToArchive.ps1 is not a valid win32 application
I tried to add the path to powershell with powershell.exe defined like so
<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>
This doesnt work either.
As can be seen from the error, MFT agent is using CreateProcess
API to start a program. CreateProcess
API can run only executable file. The Powershell
script you are using is a non executable. Hence the error.
If you want to be able to open any file with its associated application then you need ShellExecute
instead of CreateProcess
. But this is not under your control. So need to look for alternative?
Try using a batch file say ps.cmd
and in the batch file you run the PowerShell script like
Powershell -executionpolicy bypass -File C:\IBM\MFT\script\MoveFileToArchive.ps1 %1
Where %1 would be the argument for PS script.
The Ant script also needs bit of a change.
<fte:presrc command="ps.cmd" successrc="0">
<fte:arg value="${base.file}"/>
</fte:presrc>
I am sure you have already set the commandPath
property to a suitable value in agent.properties.
Give it a try.