Page 1 of 1
RunProgram bug or missing?
Posted: Fri Oct 24, 2008 11:31 pm
by Fredi
Hi
Why ShellExecute in this code work perfect:
Code: Select all
ShellExecute_(0,"open","cmd.exe","/c c:\test.exe > output.txt","c:\",#SW_HIDE)
(cmd is hide and output true)
But PB RunProgram:
Code: Select all
RunProgram("cmd.exe","/c " + "c:\test.exe" + " > output.txt" ,"c:\" ,#PB_Program_Hide)
(cmd is visible and output = Null )
Its bug or something is missing? i know about ReadProgramString but i want know why this doesn't work !
Posted: Fri Oct 24, 2008 11:57 pm
by ts-soft
RunProgram <> shellexecute!
RunProgram uses for files, not for executable, shellexecute.
For executable it uses createprocess api
RunProgram bug or missing?
Posted: Sat Oct 25, 2008 12:37 pm
by Fredi
Thanks ts-soft for info, now if i used shellexecute to run an program how can i wait until program closed? something like #PB_Program_Wait in RunProgram ?
RunProgram bug or missing?
Posted: Sat Oct 25, 2008 7:22 pm
by Wolf
ts-soft wrote:
RunProgram uses for files, not for executable...
Are you sure ts-soft? Run
Program as it say must be for programs not files.... anyway may be my mistake.
Posted: Sat Oct 25, 2008 7:31 pm
by Kaeru Gaman
try yourself:
call RunProgram with e.g. a textfile as argument.
Re: RunProgram bug or missing?
Posted: Sat Oct 25, 2008 7:34 pm
by ts-soft
Wolf wrote:ts-soft wrote:
RunProgram uses for files, not for executable...
Are you sure ts-soft? Run
Program as it say must be for programs not files.... anyway may be my mistake.
You have misunderstood, the underlaying API call, if you use RunProgram is
not always the same.
RunProgram bug or missing?
Posted: Sun Oct 26, 2008 1:10 am
by Wolf
After some test now better understand your mean, thanks
@Fredi
You can use ShellExecuteEx, this is a example:
Code: Select all
ei.SHELLEXECUTEINFO
ei\cbSize = SizeOf(SHELLEXECUTEINFO)
ei\fMask = #SEE_MASK_FLAG_DDEWAIT | #SEE_MASK_NOCLOSEPROCESS
ei\nShow = #SW_HIDE
ei\lpVerb = @"open"
ei\lpFile = @"cmd"
ei\lpParameters = @"/c dir"
ei\lpDirectory = @"c:\"
Result = ShellExecuteEx_(@ei)
For i = 1 To 300
Delay(1000) ;check for 300*1000ms if ShellExecute is done
If GetExitCodeProcess_(ei\hprocess, @ExitCode)
If ExitCode <> #STILL_ACTIVE
Break
EndIf
EndIf
Next
If ExitCode<>#STILL_ACTIVE
Debug Str(ExitCode) ;Exit code of external app
Else
Debug "Timeout" ;ShellExecute still not finished
EndIf