2

I am running Lua on a Windows 7 machine and I am trying to launch a LabVIEW executable using Lua.

This is an example of the command line input that DOES work:

cmd prompt

The text I use:

"C:\Program Files\National Instruments\LabVIEW 2009\LabVIEW.exe" "C:\Program Files\National Instruments\LabVIEW 2009\examples\viserver\cmdline.llb\CommandLine.vi" -- 4.0

However no matter how I try to format this in Lua, it complains:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

I currently have it formatted as the following with no success:

local s = [["C:\Program Files\National Instruments\LabVIEW 2009\LabVIEW.exe" "C:\Program Files\National Instruments\LabVIEW 2009\examples\viserver\cmdline.llb\CommandLine.vi" -- 4.0]]
os.execute(s)

I need help formatting that local string s to do the same as what I typed into the command prompt.

2
  • This probably isn't the issue, but try escaping the backslashes ("C:\\Program Files \\National...") Commented Jan 21, 2014 at 16:11
  • 1
    The double brackets in Lua disable escape sequences. I think the issue is a result of the spaces, but the quotes around the paths should resolve that (or so I would think). Commented Jan 21, 2014 at 16:13

1 Answer 1

4

Some quick reading online suggests that you might need to wrap your command string in an extra set of quotes. Like this I think:

[[""C:\Program Files\National Instruments\LabVIEW 2009\LabVIEW.exe" "C:\Program Files\National Instruments\LabVIEW 2009\examples\viserver\cmdline.llb\CommandLine.vi" -- 4.0"]]
Sign up to request clarification or add additional context in comments.

2 Comments

I'm not sure where you found that because I searched a good while for a solution, but that definitely solves the problem!
Don't remember what I searched for exactly but I went through the MSDN page for the system function at one point before ending up on stackoverflow.com/questions/9964865/… (which referenced documentation on cmd that I'd seen before when looking into command line parsing in cmd.exe).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.