Page 1 of 1

Execute a .bat file from a .lua script?

Unread postPosted: Fri Feb 26, 2021 4:16 pm
by mikeadams2k
I would like to be able to execute a .bat file from an engine script. Can anyone tell me if this is possible, and if so, give me an example of the code needed to make it work? I would appreciate it greatly! (I've searched the web and found a few examples, but haven't been able to make them work. Most of these examples say something like "I think this will work" or "you might try this". Nothing definitive.)

Re: Execute a .bat file from a .lua script?

Unread postPosted: Sat Feb 27, 2021 4:43 am
by bnsfsubdivision
The code below will execute your batch file on Initialisation (i.e run it once and close it).

Code: Select all
function Initialise ()

    --EXECUTE ON INITALIZATION
    os.execute([["YOURDRIVE:\PATH\PATH\PATH\FILE.bat"]])

end

Re: Execute a .bat file from a .lua script?

Unread postPosted: Sat Feb 27, 2021 8:59 am
by mikeadams2k
Kevin, thank you very much!