How to run a .bat file in Godot?

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

I am having trouble running this code.

var output = []
OS.execute(
	'"C:\\Users\\USERNAME\\Desktop\\bat.bat"',
	[],
	false,
	output
)
print(output)

I want it to run the batch file and print the result, but every time, it prints an empty array.
My batch file is very simple. It is just a hello world statement.

@echo off
echo Hello world

The expected outcome is Hello world.

:bust_in_silhouette: Reply From: Ertain

When a game runs, it only uses the files it finds in the resource path, res://, or the user’s path, user://. The script file to run on the host OS should be placed in one of these directories. See the articles, File system and Data paths, for more information.