是否可以在cfexecute中输入powershell对coldfusion的代码行响应?

是否可以在cfexecute中输入powershell对coldfusion的代码行响应?,powershell,coldfusion,cfexecute,Powershell,Coldfusion,Cfexecute,我正在尝试使用不同的属性(如errorVariable、Variable、errorFile、outputFile)将Powershell的输出返回到ColdFusion,但没有成功 冷融合码- <cfset hello = "hello"> <cfexecute name="C:\windows\system32\cmd.exe" arguments="/c start c:\windows\system32\WindowsPowerShell\v1.0\powershel

我正在尝试使用不同的属性(如errorVariable、Variable、errorFile、outputFile)将Powershell的输出返回到ColdFusion,但没有成功

冷融合码-

<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#">
谢谢

有两个问题:

  • 语法有点错误。去掉参数字符串中的
    start
    。使powerShell.exe成为可执行文件也更简单

  • 可能会导致命令在收到输出之前返回。将其增加到大于0的值,将填充变量

    。。。[默认超时0]启动进程并立即返回。寒冷的五月 在显示任何程序输出之前,将控件返回到调用页。 要确保显示程序输出,请将该值设置为2或更高

    将超时增加到大于0的值,您应该会看到结果。

  • NB:始终捕获任何错误,以便代码能够相应地处理任何问题

    <cfset inputVar = "test value here">
    <cfexecute name="c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" 
        arguments="C:\path\to\yourScript.ps1 '#inputVar#'" 
        variable="result"
        errorvariable="err"
        timeout="2">
    
    <cfdump var="#result#">
    <cfdump var="#err#">
    
    
    
    看起来不错,但如何将ps输出返回到cfexecute?谢谢,我不太明白。上面已经将
    写入主机$hello
    的结果返回给cfexecute。转储
    #结果#
    ,并显示“此处的测试值”。如果我想从powershell脚本中添加这样的文本,可以-param([string]$hello)写入主机“$hello+具有另一个ps1值”,然后返回cf?,这样应该可以正常工作。你试的时候发生了什么?
    <cfset inputVar = "test value here">
    <cfexecute name="c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" 
        arguments="C:\path\to\yourScript.ps1 '#inputVar#'" 
        variable="result"
        errorvariable="err"
        timeout="2">
    
    <cfdump var="#result#">
    <cfdump var="#err#">