0

I am trying to start an executable by lua. Lua function is called in a thread by c#. os.execute starts a .bat file, which is kept at the same location as the program but not able to start the program.

os.execute('D:/startApplication.bat')
os.execute('D:/application.exe')

The top line works while the bottom one doesn't.

This question differs from How do I run an executable using Lua? because I am using lua in .net environment. And solution given in that question is not working for me.

Akj
  • 7,038
  • 3
  • 28
  • 40
Amit Kumar
  • 620
  • 4
  • 17
  • This is the method. If you can run a .bat and not the .exe, it still means you have using the correct way of running an executable. Why the .exe file is "not working" is probably not linked with lua directly. As a complete guess, I would say it might be Windows preventing arbitrary exe file to be executed, or a problem of current working directory needed by application.exe. Try to run your LUA program (or Visual Studio / your IDE) as an administrator, to see if it changes anything. – Pac0 Jan 10 '19 at 14:14
  • Also, how can you say that "it doesn't work" ? Do you get an exception ? other error ? (please share the message). Or you get simply... nothing ? (maybe application.exe does actually nothing in this context...). – Pac0 Jan 10 '19 at 14:15
  • There was no error or exception. A command prompt window open up and close itself within 2 seconds. Behaviour is same even if I am running application with administrator right. – Amit Kumar Jan 11 '19 at 08:49
  • Could you check here to see if the "window closing too quick" hides an error message : https://stackoverflow.com/questions/17071956/lua-command-line-remain-open-after-execution – Pac0 Jan 11 '19 at 11:09
  • Or is it the actual application.exe window ? Can you check if opening manually yoursels (by typing `D:\application.exe` in a command prompt) yields something different ? – Pac0 Jan 11 '19 at 11:17
  • adding ```os.execute('pause')``` still close the window quickly. And if i write D:\application.exe in command prompt, the program starts. – Amit Kumar Jan 15 '19 at 10:56
  • As i said, if i start a ```.bat``` file from lua and start that application in batch file then it run perfectly. But i want to avoid use of batch file. – Amit Kumar Jan 15 '19 at 10:59

0 Answers0