Jump to content

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
Link to comment

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.

Link to comment
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
Link to comment

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
Link to comment

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
Link to comment
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.

Link to comment
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
Link to comment
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.

Link to comment

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.

×
×
  • Create New...

Important Information

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