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: 

Best way to create a Windows service from a LabVIEW executable?

What would be the best way to run a LabVIEW executable as a service? I needed this recently and I think I have set up such a service using srvany.exe from the Windows 2003 Resource Kit, but that seems like a bit of a hack. The Kit is not offically supported in Server 2008, but seems to work. I don't know about Server 2012 or beyond.

 

So what would be the "proper" way of going about creating a Windows service from a headless LabVIEW application?

 

0 Kudos
Message 1 of 6
(5,151 Views)

The proper way is to interface to the according Windows service control API. That is however not a trivial task to do. We used to sell a LabVIEW toolkit which supported a full interface to this, but it's not currently actively marketed.

 

srvany.exe is sort of a hack but works reasonably well for most use cases, as long as you do not need any further interaction with the service manager interface in Windows than to start and stop your service.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 6
(5,142 Views)

You could create a Web service, other services aren't available as standard.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 6
(5,108 Views)

ShaunR on Lava mentioned running an application using the task scheduler.

 

http://lavag.org/topic/17019-run-the-labview-program-windows-background/#entry104561

 

This is not a service but it runs an application without having to login which is usually the goal.  I've never tested this but it sounds simple enough.

Message 4 of 6
(5,060 Views)

Hello,

In the past I tried srvany, but nssm (https://nssm.cc/) is much better and simple to use.
Keep in mind to discard the Event "Application Instance Close?", otherwise your Service will be stopped if the User logs off.
Also be shure that your Service will never open a Dialog, because a Service has no Frontpanel.
I can run this Application quite normal (=with Frontpanel) or as a service.

Message 5 of 6
(4,645 Views)

Hello,

Now there is a "Featured pre Release" of nssm (https://nssm.cc/download).
Now is possible to call an exe before killing the Service. You can write an LabVIEW exe which end your Service gracefully. For expamle via VI-Server.It works!

 

Message 6 of 6
(4,307 Views)