1

I have a Lua script and I want to execute a batch file from within this file; how can I do this?

I've seen examples as follows that I thought could do this but in retrospect I am probably misunderstanding their purpose:

os.execute('C:\\tmp\\MyFile.bat')  

or

local handle = io.open('C:\\tmp\\MyFile.bat')
handle:close()

I believe this question has been asked and answered before: How do I run an executable using Lua?

However my code is failing; I'm not sure why. Is there a library I need to load for 'os' for example?

When I try and run this code I get the following error:

"attempt to index a nil value"

Community
  • 1
  • 1
Gedalya
  • 899
  • 4
  • 16
  • 28

1 Answers1

1

You have to use os.execute[[yourFile.bat]] when opening a batch file.
More information for this here

Jonathan
  • 71
  • 1
  • 9