Uniface User Forum

 View Only
  • 1.  Implementing an OS Service with Windows Powershell

    Posted 02-07-2023 16:27
    While it is relatively easy to do something like this

    activate "Windows".CommandOut("cmd /c echo Hello World!", $1)
      and it is also possible to run a Powershell script with something like this

    activate "Windows".Command( "cmd /c start /wait /b /min %%"%%" powershell -ExecutionPolicy Bypass -Command %%"Write-Output (Hello World)%%" | Out-File temp.txt " )

    I have been unable to find a way to use CommandOut to capture Powershell output. Has anybody else encountered and resolved this issue? I have tried Write-Host, Write-Output and a few other variations but it does not appear that Powershell output goes where CommandOut can access it.

    ------------------------------
    Harjit Batra
    IT Director
    Rocket Forum Shared Account
    ------------------------------


  • 2.  RE: Implementing an OS Service with Windows Powershell

    Posted 10-23-2023 05:59

    Hi Harjit,

    Have you found a solution for your question. I'm also looking for a solution. I want to capture the output in a variable. If I use Commandout with two parameters (one is command and another one is $variable) the $variable is always null. But the command was executed successfully. I see the powershell window opened for a second and display the output and closed automatically. 



    ------------------------------
    Thanks,
    Satheesh MuthuGopal
    ------------------------------



  • 3.  RE: Implementing an OS Service with Windows Powershell

    Posted 10-25-2023 13:39

    Hi Satheesh MuthuGopal,

    in a previous discussion was already pointed out the only solution for time being is:
    - save the result to a temporary file into your powershell script
    - use Uniface fileload instruction to load the temporary file and fill your variable

    Hope it helps...

    Regards,
    Gianni



    ------------------------------
    Gianni Sandigliano
    IT
    ------------------------------



  • 4.  RE: Implementing an OS Service with Windows Powershell

    Posted 10-31-2023 07:20

    Hi Gianni,

    Thanks  a lot for your reply.

    It works.!



    ------------------------------
    Thanks,
    Satheesh MuthuGopal
    ------------------------------