Code: Select all
; example version
; psrun$ = "pwsh.exe" ; for powershell 7
psrun$ = "powershell.exe" ; for native PS 5
a$ = " <some ps command code here>;"
b$ = " <some ps command code here>;"
c$ = " <some ps command code here - and what ever the return is>;"
cmdx$ = "$ErrorActionPreference = 'SilentlyContinue';" + a$ + b$ + c$ ; etc...
OutProg$ = ""
KeepOutProg$ = ""
ProgRun = RunProgram(psrun$, cmdx$,"", #PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If ProgRun
While ProgramRunning(ProgRun)
OutProg$=ReadProgramString(ProgRun)
KeepOutProg$ = KeepOutProg$ + OutProg$
Wend
CloseProgram(ProgRun)
EndIf
ProcedureReturn = Trim(KeepOutProg$)
Yes, you can run powershell code in Windows Terminal in Windows 11, the executable is called wt.exe. But whats its doing for right now is actually using powershell in the background. So I wanted to try using Windows Terminal to see if I can start modifying my code for my powershell stuff to use wt.exe and not powershell 5 or 7. So far I have not been successful - It runs wt.exe fine but there is never any return from Terminal and I'm not sure its even sending the code to terminal even with the #PB_Program_Write flag used (yes I tried various incarnations, and also using WriteProgramData,
WriteProgramString, WriteProgramStringN.
So what am I doing wrong - how is it done?