AnsweredAssumed Answered

Can't get Windows COM command to run using BAT option via Process tab

Question asked by eric.felker on Dec 9, 2013
Latest reply on Dec 11, 2013 by eric.felker

Hi all,

I'm having a heck of time getting a Windows command to run by selecting WINDOWS tab > BAT and putting the command in the Process tab. I can get the same command to run without issue using the COM option in the WINDOWS tab and using the Command field. The command:

powershell.exe (Get-Content "&UC4RBPARAM1#") | % {$_ -replace '&UC4RBPARAM2#', '&UC4RBPARAM3#'} | Set-Content -path '&UC4RBPARAM1#'

What is especially frustrating is that the command is nearly a direct copy of an example RUNBOOK object (UC4.RB.WIN.REPLACE.TEXT.IN.FILE), which has the command in both places (WINDOWS tab > Command field and Process tab), although the line in the process tab has been commented out in favor of the WINDOWS > Command field. I would think if this command wouldn't work in the Process tab, it should not have been left behind, commented or not.

So my question: how can I get the command to work in the Process tab? I want to do this so I can run additional commands, to verify that the text replacement was successful for instance. However, the command is not parsed correctly when placed in the Process tab, and results in the following error:

c:\>powershell.exe (Get-Content "D:\uc4\Agents\windows\bin\UCXJWX6.ini")   | \uc4\Agents\windows\bin\UCXJWX6.ini'
'\uc4\Agents\windows\bin\UCXJWX6.ini'' is not recognized as an internal or external command,
operable program or batch file.

See that much of the original command is missing: "% {$_ -replace ", and it fails thinking\uc4\Agents\windows\bin\UCXJWX6.inishould be a command.

I figure a syntax change should make this work, and I've tried a bunch of things trying to quote or escape the command, but the answer eludes me. I've also tried replacing all of the variables with their appropriate strings, to remove that extra complexity. Still get the same. Any thoughts are very appreciated!