I want to open a new command prompt, run an program and save the output (which is right now displayed in the command prompt) in a logfile.
I used this command so far:
cmd /c start "window title" "C:\Program Files\app.exe"
normally I can use
"C:\Program Files\app.exe" >out.txt
to save what is written on the command prompt in a file. With the need, that the programm is executed in another window, I'm struggling to set the output correctly.
Why do I need the extra window?
--> The program will be called several times. I need a license for that, I'm limited there. If the program is called in the same window, after 3 three times an error occurrs, telling me, that I use to many license at the same time.
With extra opening and closing windows this "license problem" is solved.
But the I cannot find the solution for the output then.
Lua is tagged, since this command is embedded in Lua's os.execute()
Windows command line has wicked rules about quoting :-)
This code works as you need:
os.execute([["start "window title" cmd /C ""C:\Program Files\app.exe" > "C:\my logs\log.txt"""]])