I'm running into a problem. (I'm pretty sure this has already been mentioned in connection with the PB compiler calls).
What is my problem:
=> I'm missing the “error output” in RunProgram.
My Test Case (only for this message)
I've created a small example with copy. (The steps to reproduce are described in the output print.)
I copy files using the Copy command, then write-protect one target file and repeat the command...
Code: Select all
; Example to show my problem.
; HINT: It is not about the Copy command itself. It is about the missing error message.
;
Global cmd$
cmd$ = "copy /y/v c:\temp\*.ini r:\" ; ret = 0 (success) or 1 (failure)
ProcedureDLL RunCommand(Command$, WorkingDirectory$="")
Protected result, NProgram, t$
NProgram = RunProgram("cmd.exe", "/D/C " + Command$, WorkingDirectory$, #PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
If NProgram
While ProgramRunning(NProgram)
If AvailableProgramOutput(NProgram)
out$ = ReadProgramString(NProgram) : Debug "OUT: " + out$
EndIf
t$ = ReadProgramError(NProgram) ; Extra double, I didn't want to miss anything.
If t$ : Debug "ERR: " + t$
EndIf
Wend : Debug ""
t$ = ReadProgramError(NProgram) ; Extra double, I didn't want to miss anything.
If t$ : Debug "ERR: " + t$
EndIf
result = ProgramExitCode(NProgram) : Debug "Exitcode: " + Str(result)
CloseProgram(NProgram)
EndIf
ProcedureReturn result
EndProcedure
RunCommand(cmd$, "")
Code: Select all
; Command Prompt: use this copy /y/v c:\temp\*.ini r:\
;
; First Run --> success.
; c:\Temp>copy /y/v c:\temp\*.ini r:\
; c:\temp\aaa_test-setup.ini
; c:\temp\AH.INI
; c:\temp\AH2.INI
; 3 file(s) copied.
;
; To prepare an Error set (one) target file to 'Read-Only'
;
; Second Run --> success.
; c:\Temp>copy /y/v c:\temp\*.ini r:\
; c:\temp\aaa_test-setup.ini
; c:\temp\AH.INI
; c:\temp\AH2.INI
; Access is denied.
; 2 file(s) copied.
;
; Debug Output:
;
; Second Run --> Missing line in output. Everything else (the files, the exitcode) is ok.
; OUT: c:\temp\aaa_test-setup.ini
; OUT: c:\temp\AH.INI
; OUT: c:\temp\AH2.INI
; OUT: 2 file(s) copied.
;
; Exitcode: 1
Perhaps there is an explanation for this?
I would be grateful if someone could share this with me.

