0 votes

I want to write a program that first uninstalls another program and then deletes itself with its parent folder.

Is this possible? Is it only possible to transfer it to the %TEMP% folder?

in Engine by (220 points)

Why wouldn't it be possible? But I'm not sure why this is a Godot-specific question, especially since you can bundle a Godot game as a single executable that doesn't actually need any kind of installation besides dropping it somewhere into the filesystem. Uninstalling the game then consists of deleting the file.

I want a programm that deletes my game and then itself, but this code won't work.
(deleting the DeleteProgramm)

What error do you get from Directory.remove? And what version of Godot are you running it on? This is important because the behaviour of Directory.remove was changed several times in 3.2, and depending on which version you use, it works a bit differently.

Godot Version: 3.2.4 RC3

Error: 1 (Generic error)

I did not know that the folder must be empty. Unfortunately I can only delete the pck, not the exe file of my delete program (which is currently running).

1 Answer

0 votes

If you use


You're trying to delete a directory which isn't empty, because it contains the executable. That doesn't work. You need to delete the executable file first, and then the directory.

In addition to that, I'm not sure whether you need to pass Directory.remove a prefix that tells it to use your actual file system root, because Directory.remove might work relative to your res:// folder by default. Probably isn't a problem, though, since OS.getexecutablepath will hopefully return an absolute path that's recognized by Directory.remove as such.

Note that depending on which version of Godot you're using, the semantics of Directory.remove work out slightly differently.

by (295 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 Frequently asked questions and 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 [email protected] with your username.