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 post

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 post
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 post

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.

Link to post

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.

Link to post

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 post

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 post
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 post
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 post
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 post

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 drjdpowell
      I am just starting on trying to be able to use Python code from a LabVIEW application (mostly for some image analysis stuff).  This is for a large project where some programmers are more comfortable developing in Python than LabVIEW.  I have not done any Python before, and their seem to be a bewildering array of options; many IDE's, Libraries, and Python-LabVIEW connectors.  
      So I was wondering if people who have been using Python with LabVIEW can give their experiences and describe what set of technologies they use.
    • By Billy_G
      Hello, I wrote a LabVIEW program to communicate with a hardware sensor using vendor-provided LLB and a DLL files. The program runs fine on my workstation both from LabVIEW IDE and from a compiled executable. The problem starts when I copy the entire executable folder to a target host without a LabVIEW IDE (only with a runtime engine). The application opens with a broken Run arrow and a "missing external function" error message appears for every function call I made to the DLL (see attached).
      I have tested my application on 5 completely different Windows 10 computers managed by different people. On three of them with various versions of LabVIEW IDE my executable opened with a whole Run arrow and no error message. Two other machines previously had no LabVIEW, so I installed a Runtime Engine 2017f2 32-bit with default settings to match the version of my IDE. Both gave an identical error message.
      The DLL is always included in the application build. I have tried placing the DLL in every conceivable location on the target host: in the executable folder, in the /data folder, in the c:\Windows and system32 folders... I even created a full folder tree matching the location of the project on the developer workstation. Same error. When I intentionally hide the DLL, my executable prompts me to point to it upon being opened, and when I do, I get all the same error messages.
      Vendor documentation only asks to put the two files in the same folder. From programmer's manual: " The driver was written in LabWindows/CVI, version 4.0.1 and is contained in a dynamic link library which can be linked with a variety of programming languages." There is no vendor-provided support.
      One way I actually got rid of the error message was by editing every Call Library Function Node in every VI in the LLB to use relative path to DLL together with the Application Directory VI. However, I feel that there has got to be a better way to compile than by editing a vendor-provided library, especially since it works as-is on some computers. Can anyone suggest what it is?
      Thank you for your time!
       

    • By Yaw Mensah
      I have installed Labview 2020 on Dedian Buster using the rpm to deb conversion method via alien. Due to Architecture mismatch i deleted the *i386.rpm files before conversion.
      My Problem is that after creating a project at "Build Specification"-> "rigth click" i am only able to select "Source Distribution". Application does not show up as an option. 
      I will be grateful for any suggestions.
      Thank you in advance.
    • By javier_r
      VIPM.io now allows you to post LabVIEW Resources, Ideas, and Tools. For example, you could post a link to a video tutorial or blog article about a package. You can also post ideas, like feature requests or new tools. Best of all, package developers are notified when you post your ideas and resources, and you can comment and discuss posts with the community. Take a look at this video to learn more: https://www.vipm.io/posts/664960df-f111-4e13-989a-24be8207182d/

    • By Shuvankar Das
      I want to connect My ccd camera with labview. The details of my system is given bellow. I cannot connect it please help   OS:  WINDOWS 7, 64bit   LabView Run-Time 2013(64-bit) NI-IMAQ 4.8 NI-IMAQdx 4.3   Camera: QICAM Monochrome Cooled (QIC-F-M-12-C) Model QICAM Resolution 1392 x 1040 Sensor 1/2" Sony ICX205 progressive-scan interline CCD Pixel Size 4.65 x 4.65µm Cooling Type Peltier thermoelectric cooling to 25˚C below ambient Digital Output 12 bit Video Output FireWire (IEEE 1394b) Max. Frame Rate 10 fps full resolution @ 12 bits Pixel Scan 20, 10, 5, 2.5MHz Mount Type C-mount optical format  
       
×
×
  • Create New...

Important Information

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