Jump to content
Dawid

System Exec - not possible to recognize program or batch file

Recommended Posts

I'm trying to execute LPR.exe command to print some labels on a printer. However as its normal, problems occur. I could not find answer on any topic conneced with "sytem exec". I already tried all described methods (I think so). That's why I'm asking very kindly for any help.

When trying to execute or call the LPR.exe from System exec VI, I'm receiving error:

"'C:\Windows\System32\lpr.exe' is not recognized as an internal or external command, operable program or batch file."

Generally I would like to call function: "lpr -S 192.168.1.5 -P lp C:\test\do_druku.txt" which works from command window without any problem.

 

diagram.png

print.vi

diagram2.png

Edited by Dawid

Share this post


Link to post
Share on other sites

In situations like this with a not trivial set of arguments I normally create a batch file (from code) and then run that using the System Exec, with no parameters needed.

I have done it like this for as long as I can remember so am not really sure if it is still necessary to do this.

Share this post


Link to post
Share on other sites
16 minutes ago, Neil Pate said:

In situations like this with a not trivial set of arguments I normally create a batch file (from code) and then run that using the System Exec, with no parameters needed.

I have done it like this for as long as I can remember so am not really sure if it is still necessary to do this.

Thanks for answer!

I tried this too, I create simple *.bat or *.cmd and it does not work from Labview. From command window of course do. But what you think about this picture? Maybe this is the issue? I can find a file in explorer but in cmd called by labview not. I use command dir /B/S *.exe and search on the list lpr.exe and could not find it.

search.png

Edited by Dawid

Share this post


Link to post
Share on other sites

Search the forums for calling a batch file from inside LabVIEW. Sometimes it can be a bit tricky to get the path right with the all the "" that you need.

I dont have any code in front of me that does this right now, I can dig something up in a few hours.

Share this post


Link to post
Share on other sites

I just tried with another command that is in the system folder which is "dir"  here is the command line string value I used:

cmd /c dir "C:\Example Project" /w

This was with the Working Directory being empty.

Share this post


Link to post
Share on other sites

Do these files contain printer commands? If so, you can share the printer and issue a copy command from the VI to the share.

Share this post


Link to post
Share on other sites

This works. Note in my example I do not wait for the command to complete, I test for the result in some downstream code not shown in this snippet.

 

Run Batch.PNG

Share this post


Link to post
Share on other sites

Hi,

I test all solutions. Still nothing works from labview.

13 hours ago, Neil Pate said:

This works. Note in my example I do not wait for the command to complete, I test for the result in some downstream code not shown in this snippet.

 

Run Batch.PNG

I did like on my picture, without effect. Nothing is happening, when called from labview. It seems like cmd from labview cannot see some files existing in the system.next_diagram.png

19 hours ago, Neil Pate said:

Search the forums for calling a batch file from inside LabVIEW. Sometimes it can be a bit tricky to get the path right with the all the "" that you need.

I dont have any code in front of me that does this right now, I can dig something up in a few hours.

I do not have a problem to call batch file, I can call it, but functions inside batch file are not executed when called from labview.

16 hours ago, Gribo said:

Do these files contain printer commands? If so, you can share the printer and issue a copy command from the VI to the share.

Yes, the file contain printer commands it's basically job file. The printer is Novexx 64-04, it's supporting FTP, but I do not know yet where to copy the file on a printer to print (I can open the printer files, but do not know where to copy). I will contact Novexx, maybe they will tel me something.

Generally, I do not understand, why Labview (started with administrator rights) cannot find a file, and batch file do (see picture).

 

 

diagram4.png

 

SOLUTION:

I found a method to print, but I do not like it:) I copy "lpr.exe" from "C:\Windows\System32" to other catalog, in my case is "C:\test\". Then I call the lpr.exe with parameters and printer respond. The mystery is, why Labview cannot see file in C:\Windows\System32\ catalog??!!

If anybody knows how to answer this question I will be very appreciate. Generally we can close the topic.

 

solutions.png

Edited by Dawid

Share this post


Link to post
Share on other sites

Since it is just a raw printer commands file, you can do the following (I have done it in the past with Zebra and TSC label printers):

1. Share the printer. On Windows, its Printer properties, sharing and create a share.

2. Test by running the following command: copy <filename> \\<hostname>\<sharename> . You can use localhost, if it is on the local PC.

 3. In Labview, use the .NET Copy command, as LV copy doesn't support local shares for some reason.

  • Like 1

Share this post


Link to post
Share on other sites
18 minutes ago, Gribo said:

Since it is just a raw printer commands file, you can do the following (I have done it in the past with Zebra and TSC label printers):

1. Share the printer. On Windows, its Printer properties, sharing and create a share.

2. Test by running the following command: copy <filename> \\<hostname>\<sharename> . You can use localhost, if it is on the local PC.

 3. In Labview, use the .NET Copy command, as LV copy doesn't support local shares for some reason.

I did not know it's enough to copy a file to printer name (like to folder) and that's all. I'm always learning:) Thanks, I will try this.

Share this post


Link to post
Share on other sites
On 4/10/2019 at 10:53 AM, Dawid said:

The mystery is, why Labview cannot see file in C:\Windows\System32\ catalog??!!

If anybody knows how to answer this question I will be very appreciate. Generally we can close the topic.

Short version - you're running a 32 bit process on a 64 bit OS which causes a mess as to how to correctly run LPR. Here are a couple of relevant links:

https://knowledgebase.progress.com/articles/Article/Running-OS-COMMAND-LPR-EXE-from-within-32-bit-OpenEdge-the-Procedure-Editor-fails-on-64-bit-Windows

https://docs.microsoft.com/en-us/windows/desktop/winprog64/file-system-redirector

 

The first one suggests a solution, although I haven't tried it myself.

  • Thanks 2

Share this post


Link to post
Share on other sites
On ‎4‎/‎16‎/‎2019 at 9:07 AM, Yair said:

Short version - you're running a 32 bit process on a 64 bit OS which causes a mess as to how to correctly run LPR. Here are a couple of relevant links:

https://knowledgebase.progress.com/articles/Article/Running-OS-COMMAND-LPR-EXE-from-within-32-bit-OpenEdge-the-Procedure-Editor-fails-on-64-bit-Windows

https://docs.microsoft.com/en-us/windows/desktop/winprog64/file-system-redirector

 

The first one suggests a solution, although I haven't tried it myself.

Thanks for explanation. It helps a lot.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By David Akinpelu
      I am implementing a TCP connection between MyRio(client) and Python(server). The goal is to send data from the server to the client, perform some calculations, and send the result to the server. I need to keep changing the data being sent to the client. I noticed the first data works fine and the result returned to the server, but the client could not read subsequent data. I debugged and was able to detect that the error is coming from the first read function is the "Reading values subvi"  but I don't know how to correct it. How do I go about it?
      I have attached the files below.
      Reading Unknown Bytes from TCP.vi Second_client.vi SimpleServer.py
    • By Deon
      The Threshold Hysteresis VI allows an input (for example, a sensor) to drift out of an inner limit without generating an invalid flag, but if it drifts outside an outer limit it then becomes invalid. For the reverse, when the input crosses back into the outer limit it remains invalid until the value falls inside the inner limit.
      For simplicity, only one input parameter is provided for both the inner & outer limits, and is negated for the lower limit, as generally tolerance limits are equidistant from the nominal.
    • By Deon
      View File Threshold Hysteresis v1.0 LV8.6.1
      The Threshold Hysteresis VI allows an input (for example, a sensor) to drift out of an inner limit without generating an invalid flag, but if it drifts outside an outer limit it then becomes invalid. For the reverse, when the input crosses back into the outer limit it remains invalid until the value falls inside the inner limit.
      For simplicity, only one input parameter is provided for both the inner & outer limits, and is negated for the lower limit, as generally tolerance limits are equidistant from the nominal.
      Submitter Deon Submitted 11/10/2014 Category General LabVIEW Version License Type  
    • By jossie
      Hello I am quite new to labview and I have some questions regarding labview. We have came up with a simulation build in labview as shown in the folder. However, we will be making use of Myrio to connect current and voltage sensors to send the data to labview when labview is running. We are currently having difficulties trying to search if it is possible to send the wave files and the popout messages ( messagebox.vi and Player2Wins.vi) to NI Dashboard for Labview in Ipad by using myrio. Is it possible for myrio to store wave files and the additional VIs and sending these to NI Dashboard for Labview? 
       
      Otherwise, it is possible for Labview to send the entire program.vi, messagebox.vi and Player2Wins.vi to cloud and people are able to see the GUI in program.vi remotely? ( We have found information like Labview web services etc. We hope that people are able to view our GUI and press the " Press start" button as well as closing the popout messages in a website not from our local network). 
       
      I sincerely apologize if what I am asking does not make sense to people who are reading this. I hope that someone will help me with this as it is very difficult for me to do and I need some guidance from people who are familiar with these. Thanks for taking your time to read and your reply. 
      Simulation_Build_(3).zip Pop-up_Message.vi Player2Wins.vi
    • By edupezz
      Hello, i created a new tips repository in:
      https://edupez.com/
      English and Portuguese
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.