I have a simple Lua project that runs a NodeJS script every few minutes. The NodeJS script sets a function Interval and makes a request to an API every second or so.
My Lua looks like this:
function Initialize()
Running = false
end
function Update()
if not Running then
Running = true
os.execute(table.concat({"npm", "i"}, " "))
os.execute(table.concat({"npm", "start"}, " "))
end
end
How do I keep the Command Prompt window that opens with os.execute() open? It closes after the command is finished but I want to see the output before it closes. No, I don't want the result in my Lua code, I'd just like to see the window.
Thanks in advance!
EDIT: I'm Running on Windows 10
%SystemRoot%\System32\cmd.exewith option/cto close the command process after finishing the execution of command line and the command line defined in the LUA script appended as additional arguments. So the firstos.executeresults in execution ofC:\Windows\System32\cmd.exe /c npm iand the second inC:\Windows\System32\cmd.exe /c npm start. - Moficmd /?and read the output help. There is explained how the Windows command processorcmd.exeinterprets the argument string(s) after option/Cor option/Kwhich would result in keeping command processor running after finishing the execution of the specified command line. In the command prompt window runwhere npmand output is the full qualified file name. You can see thatnpmis on Windowsnpm.cmd, a batch file which is very important to know. - Mofios.executeis something likestart "NPM" %ComSpec% /D /E:ON /K "call npm.cmd i & call npm.cmd start". That looks crazy and it is. There is started the Windows command processorcmd.exewith option/cbyos.executeto execute a command line with its internal commandstartto start one more command process with a new console window with titleNPMwith ignoring theAutoRunregistry value and with command extensions enabled to call two timesnpm.cmdwith keeping this second command process running. - Mofi