Run external application with arguments

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wrymn


I am trying to run external application with arguments.
For code test I try to run VLC with some parameters.

I Use OS.execute(), which works, opens the movie, but when I pass the arguments like
–noaudio, it doesn`t work, audio is still playing after program opens.

I tried it via normal command line, the argument opens the movie with no audio, but when running it via OS.execute(), the argument does nothing.

var array = ["--noaudio"]
var args = PoolStringArray(array)
OS.execute("D:\\Downloads\\movie.mkv", args, true)

Is the issue in my code? In the future we will need to run TexturePacker that will be creating atlases from textures, but it needs a lot of arguments.

:bust_in_silhouette: Reply From: mrLogan

Are you sure that’s the right way to call it

for example this would not work

func _on_Button_pressed():
	OS.execute("c:\\temp\\test.txt", args, true)

but this would

func _on_Button_pressed():
	var array = ["c:\\temp\\test.txt"]
	var args = PoolStringArray(array)
	OS.execute("C:\\Windows\\System32\\notepad.exe", args, true)

so in your situation you may need to include the path for VLC

You were right, the correct code was this:

var array = ["D:\\Downloads\\movie.mkv", "--noaudio"]
var args = PoolStringArray(array)
OS.execute("D:\\Programs\\VLC\\vlc.exe", args, false)

wrymn | 2018-05-02 17:31