From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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-restart an application?

Solved!
Go to solution

Hi all,

sometimes, my application (EXE) requires to be restarted (for example because user has edited some settings which requires the application to be restarted).

Is there some WINAPI method or other that allows an exe to restart itselt?

 

Thanks

0 Kudos
Message 1 of 12
(7,267 Views)

Hi i,

 

to answer your question as you wrote it:

Have the EXE call a batch file, then exit the EXE.

The batch file will wait some time (aka "until the EXE has exited"), then it simply calls the EXE again…

 

my application (EXE) requires to be restarted

Why do you think it's a good idea to exit a program and start it over? Why not have a "main" loop which simply iterates one more time?

(One reason to restart your EXE: you don't clean up in your code as much as you should do. By restarting the EXE you get fresh and clean references all over… :D)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(7,265 Views)

@sqrt(-1) wrote:

Hi all,

sometimes, my application (EXE) requires to be restarted (for example because user has edited some settings which requires the application to be restarted).

Is there some WINAPI method or other that allows an exe to restart itselt?

 

Thanks


I agree with GerdW. Likely you use some input parameters BEFORE a while loop so that is why you cannot update these values during runtime?

If so, you should refactor your application. If you programmed a proper state machine, you could have an "Update inputs from GUI" state. No need to restart your EXE...

0 Kudos
Message 3 of 12
(7,257 Views)

Hi GerdW,

 

The application restarting is required and I cannot use a sort of "launcher" or "main loop" because my application is modular and it is based on packed libraries. If user updates some of these modules (packed libraries), the only way for changes to take effect (which means to replace these packed libraries in memory) is to close the EXE and restart it.

 

0 Kudos
Message 4 of 12
(7,253 Views)

@sqrt(-1) wrote:

Hi GerdW,

 

The application restarting is required and I cannot use a sort of "launcher" or "main loop" because my application is modular and it is based on packed libraries. If user updates some of these modules (packed libraries), the only way for changes to take effect (which means to replace these packed libraries in memory) is to close the EXE and restart it.

 


Hmm, I never worked with packed LV libs, but I wonder if it is possible to load/unload them dynamically during runtime of your main application?

I have found this link, however I have no idea if this helps you...

https://forums.ni.com/t5/forums/v3_1/forumtopicpage/board-id/170/thread-id/556130/page/1

0 Kudos
Message 5 of 12
(7,238 Views)

Thanck Blokk but ,unfortunalely, it doesn't help me.

My application already loads and lunches packed libraries dinamically. If a packed library is in memory (because it has been already loaded) and a newer version of it is loded, LabVIEW or the run time engine doesn't replace the oldest packed library with the newest one. So, application restart is required.

0 Kudos
Message 6 of 12
(7,223 Views)

@sqrt(-1) wrote:

Hi GerdW,

 

The application restarting is required and I cannot use a sort of "launcher" or "main loop" because my application is modular and it is based on packed libraries. If user updates some of these modules (packed libraries), the only way for changes to take effect (which means to replace these packed libraries in memory) is to close the EXE and restart it.

 


You should be able to use a Launcher VI which'll sit in the background and relaunch as needed. Start your current program through Call VI or VI server. It should be easy enough to test. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 12
(7,217 Views)
Solution
Accepted by topic author sqrt(-1)

Hi, 

The simplest way to restart an application on windows is to use the command line.

You can use System Exec.vi in labview to pass a command to the command line.

You can pass a Multiple command to close and open again your application.

 

For example

"taskkill /IM Application.exe && Application.exe"

obviusly you must specify the path of your application

 

Steeb

 

National Instruments AE

Message 8 of 12
(7,148 Views)

Please mark the post as resolved.

 

Steeb

 

NI AE

0 Kudos
Message 9 of 12
(7,109 Views)

Hi,

 

I would like to know whether the given info is ok to restart the same application. I placed this code in boolean value change event.

I gone thru many posts related to restart the same application from labview, I found this as accepted one. But this didnt work out for me. Pls do comment where I made a mistake.

 

Thanks

0 Kudos
Message 10 of 12
(4,293 Views)