0 votes

I'm trying to run an exe file on my launcher type program & I can't seem to make it happen. I've done tests to see if the file is noticed in the system and it checks out. I just can't seem to get OS.execute() to work.

I changed my user:// directory by the way to this:

I also added an extra folder inside the user:// folder called apps using some code so keep that in mind.

Here's what my checking piece looks like,

if (app.file_exists("user://apps/app.exe")):
        OS.alert("App Found!", "Found!")

And my execute code,

func _on_Button_pressed():
    OS.execute("user://apps/app.exe", [])
Godot version 3.4.2 stable
in Engine by (29 points)

2 Answers

0 votes
Best answer

It turns out that when I try to use user:// directly, it doesn't take it but if I put the path into a variable like this:
var app_file = OS.get_user_data_dir()+"/"+"apps"+"/"+"app.exe"
And use the variable as the file path for execution, then it functions properly.

by (29 points)
+1 vote

My first thought is "does OS.execute understand what "user://" is? like, file_exists might be able to interpret that, but OS.execute might not?

Sanity checks:
- does the app run when you execute it manually from explorer?
- does onButton_pressed() actually get called?
- have you tried using the full file path instead of "user://" ?
- have you tried OS.execute("cmd.exe", ["PATH TO YOR APP"]?

Possible but unlikely issues:
- permissions? are you running as admin?
- firewall / defender?

by (1,260 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.