Get Output from PaExec

Just starting out? Need help? Post your questions and find answers here.
tatanas
Enthusiast
Enthusiast
Posts: 260
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Get Output from PaExec

Post by tatanas »

Hi,

I can't get any stdout/stderr from PaExec (equivalent to PsExec). I can't find any information on the internet if it's possible.
Can someone test this code ?

Code: Select all

p=RunProgram("paexec.exe", "-i -d calc", "", #PB_Program_Hide|#PB_Program_Open|#PB_Program_Read|#PB_Program_Error)

If p
	While ProgramRunning(p)
		If AvailableProgramOutput(p)
			o$+ReadProgramString(p)+#CRLF$
		EndIf
		
		err$ = ReadProgramError(p)
		If err$
			o$+"<ERR> " + err$ +#CRLF$
		EndIf   
	Wend
	CloseProgram(p)
EndIf
MessageRequester("Output",o$)
Windows 10 Pro x64
PureBasic 6.20 x64
User avatar
JHPJHP
Addict
Addict
Posts: 2252
Joined: Sat Oct 09, 2010 3:47 am

Re: Get Output from PaExec

Post by JHPJHP »

Hi tatanas,

I’ve added a new example to my Windows Services & Other Stuff:
- \Other_Stuff\OtherStuff\CommandConsole\ReadOutput.pb

NB*: Based on work I did in Alternate Console; recently updated.
Last edited by JHPJHP on Sun May 31, 2020 4:43 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
BarryG
Addict
Addict
Posts: 4135
Joined: Thu Apr 18, 2019 8:17 am

Re: Get Output from PaExec

Post by BarryG »

Thanks JHPJHP, that works perfectly for me. Weird that the simple short code by tatanas doesn't capture it; looks like a bug. I've reported it.
Post Reply