All you need to do is tell the application where the output should go:
B4X:
PowerShellScript("Get-Command -name *Get-app* > e:\_temp\test_output.txt")
Note: replace the path with your situation.
First of all, thanks !
The output to a file works. It's created with the datas I need.
I thought it can works without creating a file. ... and indeed, it works without a temp .txt file, read later.
However the script does not arrive to OK4; "Wait For shl_ProcessCompleted " doesn't proceed.
I'm looking for a solution about the waiting function.
SOLVED:
StartMessageLoop 'need to call this as this is a console app.
[CODE lang="b4x" title="b4j"]'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private shl As Shell
End Sub
Sub AppStart (Args() As String)
Log("Hello world!!!")
Dim lista As String
'PowerShellScript("Get-Command -name *Get-app* > c:\temp\test_output.txt")
PowerShellScript("Get-Command -name *Get-app*")
Log(lista)
End Sub
Public Sub PowerShellScript(s As String) As ResumableSub
Log("OK2")
s = s.Replace(CRLF, ";").Replace("""", "'")
Dim shl As Shell
shl.InitializeDoNotHandleQuotes("shl", "powershell.exe", Array("-Command", s))
shl.Run(-1)
StartMessageLoop 'need to call this as this is a console app.
End Sub
Sub shl_ProcessCompleted(Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
If Success And ExitCode = 0 Then
Log("Success")
Log(StdOut)
Else
Log("Error: " & StdErr)
End If
ExitApplication
End Sub[/CODE]