I'm trying to get Powershell's output back to ColdFusion with different attributes like errorVariable, Variable, errorFile, outputFile but with no success.
Coldfusion code -
<cfset hello = "hello">
<cfexecute name="C:\windows\system32\cmd.exe"
arguments="/c start c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe C:\Users\raimonds\Desktop\lala.ps1 '#hello#'"
variable="test">
<cfdump var="#test#">
And the powershell code -
param([string]$hello)
Write-Host $hello
Thank you
There are two issues:
The syntax is a bit off. Get rid of the
startin the argument string. It is also simpler to make powerShell.exe the executable.The "timeout" is likely causing the command to return before the output is even received. Increase it to something greater than 0 and the variable will be populated.
Increase the timeout to something greater than 0 and you should see the result.
NB: Always capture any errors so the code can handle any issues accordingly.