Seite 1 von 1

RunProgram() mit Parametern?

Verfasst: 22.05.2015 12:22
von Kiffi
Hallo,

folgender (leicht abgewandelter) Code aus der PB-Hilfe funktioniert. Hiermit wird eine Liste der aktuell laufenden Tasks ausgegeben:

Code: Alles auswählen

EnableExplicit

Define Program
Define Output.s

Program = RunProgram("tasklist", "", "", #PB_Program_Open | #PB_Program_Read)
If Program
	While ProgramRunning(Program)
		If AvailableProgramOutput(Program)
			Output + ReadProgramString(Program) + Chr(13)
		EndIf
	Wend
	Output + Chr(13) + Chr(13)
	Output + "Exitcode: " + Str(ProgramExitCode(Program))
	CloseProgram(Program) ; Close the connection to the program
EndIf

Debug Output
Nun möchte ich einen Filter auf die Ausgabe setzen. In der CMD würde ich folgendes schreiben:

Code: Alles auswählen

tasklist | findstr PureBasic.exe
Frage: Wie mache ich das mittels RunProgram()?

Danke im Voraus & Grüße ... Peter

Re: RunProgram() mit Parametern?

Verfasst: 22.05.2015 12:33
von RSBasic

Code: Alles auswählen

EnableExplicit

Define Program
Define Output.s

Program = RunProgram("cmd.exe", "/c tasklist | findstr PureBasic.exe", "", #PB_Program_Open | #PB_Program_Read)
If Program
   While ProgramRunning(Program)
      If AvailableProgramOutput(Program)
         Output + ReadProgramString(Program) + Chr(13)
      EndIf
   Wend
   Output + Chr(13) + Chr(13)
   Output + "Exitcode: " + Str(ProgramExitCode(Program))
   CloseProgram(Program) ; Close the connection to the program
EndIf

Debug Output

Re: RunProgram() mit Parametern?

Verfasst: 22.05.2015 12:36
von Kiffi
Danke! :allright:

Grüße ... Peter