From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to auto copy a config.ini file when building project?

Hello,

i am using LV2015Pro and created a project to build an exe file of my program.

Everything works fine besides this that i have to manually copy my config.ini file into the build-directory.

Is there a way that a rebuild of the exe-file also copies the config.ini file?

Thanks

0 Kudos
Message 1 of 5
(3,674 Views)

Well, I've solved part of this problem, and have a good idea how to solve the piece that you are describing.  Inside my Project, I have a folder called Data that I use to store Config.ini.  When you build an executable, in the same folder that the Build places your .exe, it also places a folder called (you guessed it) Data.  So I wrote a VI named Data Folder that determines whether the VI is running in Development Mode or the Run-Time System and returns the appropriate Data Folder (which I use to Build Path to whatever file I expect to find there).

     So now the only thing left is to (at Build Time) automatically copy any files in the Project's Data Folder to the (eventual) Executable's Data Folder (I'll leave it to you to decide what to do if the File is already present).  Look up Pre-Build Action (it is the next-to-last Category of things in the Build menu.  This gives you a Template and populates it with the Project Path (from which you can locate the Project's Data Folder) and the Main Destination Path (from which you can locate the Executable's Data Folder).

     If you search the Community for Pre-Build Action, you can see other uses (and a Bug I'm trying to get NI to fix) for this feature.  If you are really excited by this feature, go look up Pre-Build Action in the LabVIEW Idea Exchange, where you'll see an argument between me and the NI Developers about the meaning of the phrase "Pre-Build Action" (which I naively interpret as "Actions to be taken before the Build begins").  If you agree with my interpretation and Kudo this Idea, maybe the Developers will (re-)consider it.

 

Bob Schor

Message 2 of 5
(3,638 Views)

There is also the simple "Use Custom Config File" option inside of the executable build specification.  The config file must be in the project in order for you to select it.  But this would alleviate the need to figure out the Post Build Action.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 5
(3,626 Views)

I already found this option but it is not working.

In build properties -> category "Advanced" -> [X] use custom configuration file.

When i press there on "Select file" it shows me the correct config.ini file and path that should be used to copy to build directory.

But when building then there is no file copied.

What is the trick?

 

Edit:

next to my dummy.exe file is another file called dummy.ini.

When enabling the option above then this file contains the data of my config.ini.

When disabling the option then it contains:

 

[Dummy]
server.app.propertiesEnabled=True
server.ole.enabled=True
server.tcp.paranoid=True
server.tcp.serviceName="My Computer/VI Server"
server.vi.callsEnabled=True
server.vi.propertiesEnabled=True
WebServer.TcpAccess="c+*"
WebServer.ViAccess="+*"
DebugServerEnabled=False
DebugServerWaitOnLaunch=False

 

So i could rename my config.ini file into dummy.ini to access it but i wonder what is with the other settings that existed in the ini file normally? Are they not needed?

0 Kudos
Message 4 of 5
(3,619 Views)

OnlyOne wrote:

So i could rename my config.ini file into dummy.ini to access it but i wonder what is with the other settings that existed in the ini file normally? Are they not needed?


Technically they are needed.  I would just whatever defaults are in there from the original build and just add the sections and keys you need.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(3,609 Views)