Page 1 of 1

How do I run an external program and wait for it to finish

Posted: Sat Jul 27, 2024 9:46 am
by hdt888
I have an external program, which works with its cmd parameters. How do I run this program and wait for it to finish.

I tried RunProgram("cmd.exe",......) with optional Flags:

Code: Select all

#PB_Program_Wait|#PB_Program_Read|#PB_Program_Open
but it didn't work.

Test with PB 6.04.

Re: How do I run an external program and wait for it to finish

Posted: Sat Jul 27, 2024 9:52 am
by mk-soft
You can't combine this flage with 'Wait'

See PB-Help example: https://www.purebasic.com/documentation ... ogram.html

Re: How do I run an external program and wait for it to finish

Posted: Sat Jul 27, 2024 10:26 am
by infratec
To less informations.

Which program?

Do you need to read the output of the program?

Why cmd.exe?

Re: How do I run an external program and wait for it to finish

Posted: Sat Jul 27, 2024 12:51 pm
by hdt888
FireFox-Setup.exe /S /InstallDirectoryPath=D:\my-browsers\FireFox

Re: How do I run an external program and wait for it to finish

Posted: Sat Jul 27, 2024 1:55 pm
by infratec

Code: Select all

RunProgram("[PathToExe]\FireFox-Setup.exe", "/S /InstallDirectoryPath=D:\my-browsers\FireFox", "", #PB_Program_Wait)

Re: How do I run an external program and wait for it to finish

Posted: Sun Jul 28, 2024 6:06 am
by hdt888
I tried another way, what went wrong?

Code: Select all

RunProgram("cmd.exe", "/c @""D:\FiFox-Setup.exe" "/S " + "/InstallDirectoryPath=D:\my-browsers\FireFox"", #Null$, #PB_Program_Wait)

Re: How do I run an external program and wait for it to finish

Posted: Sun Jul 28, 2024 9:20 am
by infratec
Try it this way:

Code: Select all

RunProgram("cmd.exe", "/c D:\FireFox-Setup.exe /S /InstallDirectoryPath=D:\my-browsers\FireFox", "", #PB_Program_Wait)

Re: How do I run an external program and wait for it to finish

Posted: Sun Jul 28, 2024 9:28 am
by boddhi
hdt888 wrote: Sun Jul 28, 2024 6:06 am I tried another way, what went wrong?
Contiguous double quotes!

[EDIT] Oupps Infratec, you've been faster :mrgreen: :wink: