Trouble With RunProgram()

Just starting out? Need help? Post your questions and find answers here.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Trouble With RunProgram()

Post by chris319 »

I'm having trouble running a program called "ffprobe.exe". RunProgram() returns 0. I've checked permissions and none are set to "deny".

I'm able to run another program in the same folder called "ffmpeg.exe" RunProgram() returns 1.

Any ideas why?

OS is Windows 10.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Trouble With RunProgram()

Post by Olli »

Check if the pipes are required, adding the following options :

Code: Select all

#PB_Program_Open
#PB_Program_Read
#PB_Program_Write
#PB_Program_Error
You can see the syntax to use to setup many options in the same time in the example in the RunProgram() documentation page.
You have to use '|' (OR binary gate) to do this.

PS : I apologize for my << in the... in the... in the... >> bad language...
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Trouble With RunProgram()

Post by chris319 »

Sorry, I tried adding these flags and it still returns 0:

Code: Select all

#PB_Program_Open|#PB_Program_Read
I can run ffmpeg.exe without any flags, just the name of the executable name without the file extension, and it returns 1, which means it successfully ran.
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Trouble With RunProgram()

Post by infratec »

Please post the original line where you call it.
Without no testing is possible.

Btw. if I use the file from https://ffmpeg.zeranoe.com/builds/ static linked it works without problems.

Do you use a dynamic linked file?
Have you all needed dlls?
Did you set the "working directory" ?
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Trouble With RunProgram()

Post by Marc56us »

I can run ffmpeg.exe without any flags, just the name of the executable name without the file extension, and it returns 1, which means it successfully ran.
:arrow: Alway use full filename with extension.
:!: without the extension, there may be a .cmd, .bat or other associated extension running in its place.


This works for me (return 1)

Code: Select all

Debug RunProgram("C:\Shotcut\ffprobe.exe", "", "")
(Shotcut is a free video editor that use ffprobe.exe)

Try this too, you will seen output console (change path to your ffprobe.exe)

Code: Select all

RunProgram("cmd", "/k C:\Shotcut\ffprobe.exe -version", "")
This will output something like:

Code: Select all

ffprobe version n4.2.4-2-gd359b75 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 5.5.0 (GCC)
...
:wink:
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Trouble With RunProgram()

Post by chris319 »

Here is the line of code:

Code: Select all

result = RunProgram("ffprobe.exe","","",#PB_Program_Open|#PB_Program_Read) : Debug result
It makes no difference if I include the file extension or not.

This code runs ffmpeg and returns 1, whether I do or do not include the file extension:

Code: Select all

result = RunProgram("ffmpeg") : Debug result
I am using the static builds from Zeranoe.

Question: does RunProgram() work with batch files or just .exe files?
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Trouble With RunProgram()

Post by chris319 »

I tried RunProgram() on ffprobe in my copy of Shotcut and it worked. Bizarre.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Trouble With RunProgram()

Post by Marc56us »

Question: does RunProgram() work with batch files or just .exe files?
Yes, RunProgram() launch any program, batch or document if associated in system.
Batch (.cmd, .bat) is associated with cmd.exe for NT and command.com in Windwos 9.x so no need to use cmd /c or /k
You can use start.exe if need more option (start /? for option)

Code: Select all

I tried RunProgram() on ffprobe in my copy of Shotcut and it worked. Bizarre.
Bizarre, yes.
Maybe you have more than one ffprobe.exe in folders in path ? This is why I suggest to use fill path and extension.

If many exe, check version of each

Code: Select all

ffprobe.exe -version
:wink:
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Trouble With RunProgram()

Post by chris319 »

ffprobe requres several .dll files in order to run. Once found, it works.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Trouble With RunProgram()

Post by Olli »

In this way (DLL requirements), no pipe flags.

RunProgram() has 3 first arguments :

Name$
Parameter$
WorkDir$

Name$ : the full path + "ffprobe.exe"
Parameter$ : I ignore what to add here for now
WorkDir$ : the full path of the DLLs

An other way consists in copying DLLs in the same path as the executable file.
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Trouble With RunProgram()

Post by infratec »

chris319 wrote: I am using the static builds from Zeranoe.
The static build needs no dlls :wink:
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Trouble With RunProgram()

Post by chris319 »

infratec wrote:
chris319 wrote: I am using the static builds from Zeranoe.
The static build needs no dlls :wink:
Sorry to contradict you, but ffprobe does. It won't run without them and will run with them.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Trouble With RunProgram()

Post by Olli »

A detail however about pipes : Could you test the error channel ? (#PB_Program_Open | #PB_Program_Error)
We expect an error thanks to ReadProgramError()

I find it is strange that no warning message appears when any DLLs miss.
Post Reply