Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Install Application as Windows Service in LabVIEW

1. Overview:

This VI will automate the process of installing a application as a windows service to run in the background

 

2. Description: 

This VI automates the steps described in the following KB in order to install an application as a Windows Service:

http://digital.ni.com/public.nsf/allkb/21BA0F671A63A60386256CB4004DF99B?OpenDocument

 

It requires that the Microsoft Resource Kit be installed. This kit can be installed for the following operating systems:

    • Windows XP
    • Windows Server 2003 family
    • Windows 7 

When installing the Microsoft Resource Kit in Windows 7, a compatibility issue pop up will appear. Skip it and continue with the installation.

 

3. Requirements

  • LabVIEW 2012 (or compatible)

4. Steps to Implement or Execute Code

  1. Assure that Microsoft Resource Kit is installed 
  2. Run LabVIEW as administrator
  3. Select a service name, provide application path and SrvAny.exe path (by default c:\Program Files\Windows Resource Kits\Tools\srvany.exe)
  4. When the process is complete check the service is created in Windows Service list

 5. Additional Information or References 

VI Snippet

Block Diagram.JPG

**This document has been updated to meet the current required format for the NI Code Exchange.**

Sappster
Comments
Active Participant D60
Active Participant

Perfect!    

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
Active Participant Joe_Guo
Active Participant

It worked nicely, however, if the service name has space in it, it must be enclosed within a pair of quotes "%s".  In fact, i used this with a "Format Into String" primitive vi:

"%s" "%s" "%s"

in details:

"path_to_instsrv.exe" "my service name" "path_to_srvany.exe"

English (auto-detected) » English
Active Participant Rashid-Malik
Active Participant

Service name with spaces and version number does not work. Any solutions? No even surrounding the service name with quotes did not help. The service name would register but then it would not start, not even manully, from windows services applet.

Member GretchenSkellyZimmer
Member

will this work for Windows Server 2008?

Member Sappster
Member

GretchenSkellyZimmer, I cannot confirm that it does but this post suggests that it will work: http://social.technet.microsoft.com/Forums/en-US/winserverMigration/thread/98a97aee-c62b-4683-94ab-3...

Sappster
Member mo786
Member

I am running windows server 2008 R2 64bit. I noticed that on the Microsoft Resource Kit download page, the notes at the requirements states that it will not supported on 64 bit platforms. What should I do in this case?

Active Participant battler.
Active Participant

Is this solution still applicable for Windows 7 and 8.1??

Member Sappster
Member

Hi Battler,

I haven't tried this code on windows 7 or 8 so I can't confirm. Best thing to do would be try it and report back on your findings. I did however find this forum that suggests that the Windows 2003 Resources will function in later versions of the OS, but that it might have limited capabilities.

If I find time to test it I will let you know what I find.

Sappster
Member RJ_15
Member

Hi,

I had tried it on a Win7 machine and am getting Error2- LabVIEW memory is Full error.

Any ideas ?

Runjhun.

Member Sappster
Member

That sounds like a run-time issue related tot the application. Do you receive any issues when you are installing the service? Can you create a simple application to test that the service installs correctly?

Sappster
Member RJ_15
Member

This error is coming from the System Exec.vi function. Hence, the service is not created/installed.

Member RJ_15
Member

I have resolved the error now. The changes are refelcted in the registry but it doesn't have the registry key 'Application' = "App path".

And its not visible in the 'servcies.msc' list.

Member Sappster
Member

Create indicators for the system exec standard output and error output. I ran a test on a win 7 computer and received permissions errors for the instsrv call. You will have to run this with administrative privileges. You might find this forum thread of interest: Running system exec vi as administrator in win7

Sappster
Member Antipholus
Member

Note: The Windows Server 2003 Resource Kit Tools are not supported on 64-bit platforms.This is from the system requirements at the Microsoft download site. So... how does one install a LabVIEW application as a WinService on Win 7 - 64-bit since this resource kit cannot be used.

Not applicable

Hello,

I did it the same way. It is a pain. But I found that it is much easier with this: https://nssm.cc/

It has an User Interface to create the Service easily.
It much better & Freeware and there is also a 64 Bit Version.

Member Kegraus
Member

It is working on W7 without any problems.