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

Just starting out? Need help? Post your questions and find answers here.
hdt888
User
User
Posts: 57
Joined: Sun Jul 07, 2024 8:42 am

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

Post 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.
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post by mk-soft »

You can't combine this flage with 'Wait'

See PB-Help example: https://www.purebasic.com/documentation ... ogram.html
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

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

Post by infratec »

To less informations.

Which program?

Do you need to read the output of the program?

Why cmd.exe?
hdt888
User
User
Posts: 57
Joined: Sun Jul 07, 2024 8:42 am

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

Post by hdt888 »

FireFox-Setup.exe /S /InstallDirectoryPath=D:\my-browsers\FireFox
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

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

Post by infratec »

Code: Select all

RunProgram("[PathToExe]\FireFox-Setup.exe", "/S /InstallDirectoryPath=D:\my-browsers\FireFox", "", #PB_Program_Wait)
hdt888
User
User
Posts: 57
Joined: Sun Jul 07, 2024 8:42 am

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

Post 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)
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

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

Post 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)
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

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

Post 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:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Post Reply