01-04-2016 01:28 AM
Hi Everyone,
I am using "system executable" function in labview to run a specific batch file, which is placed in D drive, it doesn't work and gives an "error code 193" and some times popup window appears with message memory full.
But when the same path of batch i enter in command prompt then its working fine , can anyone tell me where i am doing wrong, and how to execute same command using system executable.
01-04-2016 03:29 AM
Have you tried adding "cmd /c" before your executable string? If you had showed us your code it would have been easier to diagnose the problem.
01-05-2016 08:02 AM
Yeah for the string input I usually need something like "cmd /c "<path to batch file>"" Using this format allows for spaces to be in the path to the batch file.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
08-19-2021 02:25 PM
I have the following script I am trying to launch via the LabVIEW System Exec.vi
step.pyw -w=C:\Projects\SLAM_ER\ATE\step_workspace --icfgs=full_ita.txt,Main_DAQ.txt,test_intf_ECU_serial.txt,test_intf_ITA_serial.txt --mode=normal --prescript=disable ATP_Actuator\ATP_Actuator_7_01_continuity_test.py -rc --summary=summary1.log
It's a python script which launches just fine from the Command Prompt, but the System Exec.vi throws error code 2 stating no listeners, like it's being interpreted as a GPIB command or something??
Any ideas?
08-19-2021 03:51 PM
You perhaps should have started your own thread instead of dragging up one that was several years old to ask a question that was only loosely related to the original thread.
Either way... as suggested earlier in this thread, try posting your LabVIEW code. It's much easier to debug real code instead of making wild guesses as to what might be wrong.
In the absence of code though, here is one wild guess. Give the full path to every file referenced, including python3.exe. Your command line into system exec might look something like this:
cmd /c c:\program files(x86)\PathToPython.exe c:\PathToPyFile\step.pyw -w=......
08-20-2021 06:35 AM
LabVIEW System Execute only simply launches a process. There is no command line interpreter, since that is a seperate program called cmd.exe that you actually start when you click the command line icon.
So unless the first parameter is a file that is actually a real Windows executable, the CreateProcess() call that SystemExec calls simply returns an error, which sometimes gets not translated in a useful LabVIEW error but simply returned by SystemExec too, which results in some pretty unlogical error messages.
Your first parameter is a pyw file, which is NOT executable in itself under Windows. The Windows shell will try to find an executable file that is registered for the pyw extension and launch that, but SystemExec is not going through the Windows Shell.
By adding cmd.exe as first parameter, SystemExec has a real executable program to start, and the cmd.exe will then interpret the remainder of the command line and do things like starting the associated executable that knows how to deal with your step.pyw file.
There is a Windows API ShellExecute() that in fact would do these things automatically but that has other implications that would make the SystemExec() VI not backwards compatible anymore. When SystemExec was added to LabVIEW, the ShellExecute() Windows API was in fact a mainly undocumented Windows API (The whole Windows Shell API was for a large part undocumented and Microsoft only started to really document it after it was forced by a court decision to do so).
08-20-2021 07:08 AM
Thank you, that's exactly what I needed. I thought as long as I loaunched from the working directory where the Python executable resided, I was ok, but this solved my issue.
Appreciate the help.
08-20-2021 09:45 AM
Note that the solution from BowenM to call the Python executable instead should even work if you leave the cmd.exe away. python.exe is a fully executable program and therefore SystemExec will launch that too and then pass the remainder of the command line to it and hopefully the executed program (in the case of python.exe that is the case) reads its own command line and process it accordingly.
08-20-2021 10:02 AM
using python.exe in front of the script works, and so does pythonw.exe launches without the Command Prompt window visible (silent)