LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Relative path

Hi,

I am trying to run a .bat file (i.e. “mybatfile.bat”) from the tools menu. At the moment I manage to do that by customizing the Tools Menu: Tools-->Customize-->Add then in the “Menu item name” box I use “RunBatFile” and in the “Program Name” box I use the “Browse” facility to navigate and select the “mybatfile.bat” file.  Everything work fine however, the content of the file “mybatfile.bat” differs from project to project and, instead of creating new menu items for each project I would like to create a .bat file for each project and get the relative path to it in the “Program Name” box.

Is there any way of doing that?

 

Thank you!

0 Kudos
Message 1 of 2
(2,308 Views)

I created this schema that should address your problem.

 

Let's suppose your target batch file is the simplest of all:

@echo off
echo The target folder is %1
pause

this prints in a command prompt the name of the first parameter received and waits for the user to press a key.

This batch file is located somewhere on your system, e.g. c:\myfolder\mybatchfile.bat.

 

Now in your project folder you must create another batch file that calls the first one passing the appropriate parameter:

call c:\myfolder\mybatchfile.bat %~dp1

This file calls the preceding one passing the drive and pathname only extracted from the first parameter: of course you must pass a valid pathname to it.

 

Finally, create a tools menu option this way:

Screenshot 2017-07-17 09.14.19.png

%FILE% will have the name of the filename open in the active window of the workspace (or the workspace itself if no file is in editing).

 

If you do not have the calling batch file in the project folder you will receive an "Unable to execute command line" error message.

 

To understand that strange "%~dp1" clause, open a command prompt and enter "CALL /?" to see the help on the command.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,286 Views)