LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to run batch file using System executable

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.

 

 

0 Kudos
Message 1 of 9
(4,287 Views)

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.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 9
(4,267 Views)

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.

Message 3 of 9
(4,221 Views)

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?

0 Kudos
Message 4 of 9
(2,631 Views)

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=......

0 Kudos
Message 5 of 9
(2,624 Views)

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).

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 9
(2,598 Views)

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.

0 Kudos
Message 7 of 9
(2,594 Views)

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. 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 8 of 9
(2,580 Views)

using python.exe in front of the script works, and so does pythonw.exe launches without the Command Prompt window visible (silent)

 

0 Kudos
Message 9 of 9
(2,576 Views)