6

I'm trying to open a .exe to program a PLC from LabVIEW. I have the .exe included in the project files, it's also included as a source file, so it gets installed within the install directory when installing this tool. The issue is sometimes when opening (and all the time when closing) I get the Error 2: Memory Full error.

enter image description here

Here is a snippet of the what I'm currently doing using the SystemExec.vi included with LabView:

enter image description here

And you can see here that I have the files included in the dependancies (sorry for lines, don't want to show certain .vis and certain file names for client sake):

enter image description here

Let me know if I'm doing something wrong or if there's a better way to launch an external .exe from LabView.

Thanks in advance!

biggi_
  • 266
  • 3
  • 12
  • Aside from fixing the cause of this error message, how is this code supposed to exit? If you're stopping it with the 'abort' toolbar button you may be leaving things in an indeterminate state. Have an event or condition that passes a True to your loop's stop terminal. – nekomatic Jun 16 '16 at 11:08
  • There are multiple event structures within the while loop that open sub vis. There is also an event of a panel close that will exit the program when the windows x is clicked. – biggi_ Jun 16 '16 at 12:21
  • I hope you mean multiple event cases not multiple event *structures*. Are you then using the Quit LabVIEW function to exit? The clean way to do this would be to trap the *Panel Close?* event (note the question mark), perform any cleanup such as closing files and references, exit from all loops, and only then Quit LabVIEW, and for easier development, only do that if your program is running as a built application. The *Panel Close* event case may not execute properly unless you add code to stop LabVIEW exiting first: http://zone.ni.com/reference/en-XX/help/371361K-01/lvprop/vi_pnl_closing/ – nekomatic Jun 16 '16 at 13:02
  • Yes cases, not structures. And yes I'm using the question mark one. – biggi_ Jun 16 '16 at 13:10

1 Answers1

6

Try changing your input string to "cmd /c fploader.exe"

Using the System Exec VI is not the same as typing a command into a command prompt; instead, it is like typing a command into the "Run..." window.

See here: http://digital.ni.com/public.nsf/allkb/EA1600EBA422E97286256AA20073C616

Edit: Here is how you could create the string command with the complete path of your exe: enter image description here

RomCoo
  • 1,868
  • 2
  • 23
  • 36
  • I've looked at that, the issue is I'm not working with a batch file. After I tried putting what you put I got: Error 1 occurred at 'fploader.exe' is not recognized as an internal or external command, operable program or batch file. – biggi_ Jun 15 '16 at 19:54
  • you could try the whole path of your fploader.exe insted. But of course that would be a problem when installing your LabView application to a different location. – RomCoo Jun 15 '16 at 20:13
  • Yup that's the issue. The installer is set to install to [Program Files], but that is different for both 32 and 64 bit OS's. So I'm not quite sure where to go from here. IS there a different way to open a .exe from a vi? – biggi_ Jun 15 '16 at 20:16
  • 1
    You could use this VI: https://zone.ni.com/reference/en-XX/help/371361H-01/glang/application_directory/ to get the path of your executable and then build your string dynamically – RomCoo Jun 15 '16 at 20:24
  • Use that in the SystemExec.vi as the working directory? then just the cmd /c fploader.exe? – biggi_ Jun 15 '16 at 20:35
  • that does appear to work and allows everything to open (putting the path to the working directory and then using the cmd /c fploader.exe on the command. However, when I close fploader.exe after the LabView has opened it, I still get the Memory is Full error and the LabView freezes. Any ideas? Once we get this fixed I'll mark your reply as the answer :D – biggi_ Jun 15 '16 at 20:46
  • you should add the path to the command string by converting it and then using *Concatenate Strings.vi* . something like this: `cmd /c "PATH/fploader.exe"`. But it seems that your error comes from somewhere else. – RomCoo Jun 15 '16 at 21:31
  • What also could help is to set the *wait until completion* parameter of the System Exec VI to false. – RomCoo Jun 15 '16 at 23:58
  • Sounds as though fploader.exe may not be exiting properly, hence the freeze. Do you need LabVIEW to wait for it to finish or can you use @RomCoo's suggestion? For the avoidance of doubt I don't think this error has anything to do with memory - you're seeing one of those throwbacks to the early days of LabVIEW before error codes were properly systematised I think. – nekomatic Jun 16 '16 at 09:52
  • Another point, if you **do** need to wait for the System Exec to complete then you shouldn't be calling it inside the event structure as you will be unable to respond to further events while it's running - look at e.g. a queued message handler pattern instead. – nekomatic Jun 16 '16 at 11:10
  • @RomCoo so when I take out the "return code" everything works fine. It also works with the "return code" if I hit Cancel inside fploader instead of the X. It's weird...but I'm going to go ahead and fly with it. Thanks for the help with the directory path constant, that seemed to solidify everything (especially moving directories). Thanks again! – biggi_ Jun 16 '16 at 12:23