cfexecute with pipe(|) character command not working

575 Views Asked by At

I am trying to execute an sc query command:

<cfexecute name = "sc"
  arguments='\\192.168.7.152 queryex type= service state= all | find "Apache2.2"'
  timeout = "10" variable="scVal">
</cfexecute>

<cfdump var="#scVal#">

But it fails with the error message: "Timeout period expired without completion of sc". Yet, if I run it via the command prompt, it works.

Executing the single command below also works:

<cfexecute name = "sc"
    arguments = '\\192.168.7.152 queryex type= service state= all'
    timeout = "10" variable="scVal">
</cfexecute>

<cfdump var="#scVal#">

I guess it can't recognize that it is a double command or there is a pipe character issue.

1

There are 1 best solutions below

0
On

To make the pipe command work try adding a caret (^) as the escape character

<cfexecute name = "sc"
  arguments='\\192.168.7.152 queryex type= service state= all ^| find "Apache2.2"'
  timeout = "10" variable="scVal">
</cfexecute>

<cfdump var="#scVal#">