Most Dynamics NAV databases have more than one companies.  When setting up Dynamics NAV Application Server as a service, you have to install a service for each company in your database.  Your license might not have enough user licenses to be able to run all services at once.  My solution is the following.

I install a NAS service for each company.  One of them set to automatic startup type, all others are set to manual. I then schedule a task every 30 minutes and execute a script that I save as NAS-Rotate.vbs.
[code lang=”vb”]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & _
"\root\cimv2")

CurrentServiceName = ""
RunNextService "NAS-1","NAS-2"
RunNextService "NAS-2","NAS-3"
RunNextService "NAS-3","NAS-4"
RunNextService "NAS-4","NAS-5"
RunNextService "NAS-5","NAS-6"
RunNextService "NAS-6","NAS-1"
If CurrentServiceName = "" Then
StartService "NAS-1"
End If

Sub RunNextService(ServiceName,NextServiceName)
Set colServices = objWMIService.ExecQuery _
("SELECT * FROM Win32_Service WHERE Name = ‘" & ServiceName & "’")

‘* List all the services on the machine
For each objService in colServices
If objService.State = "Running" Then
‘* WScript.Echo "Stopping: " & objService.DisplayName & "," & _
‘* objService.StartName & "," & objService.State
objService.StopService
StartService(NextServiceName)
CurrentServiceName = NextServiceName
‘* WScript.Quit
End if
Next
End Sub

Sub StartService(ServiceName)
Set colServices = objWMIService.ExecQuery _
("SELECT * FROM Win32_Service WHERE Name = ‘" & ServiceName & "’")

‘* List all the services on the machine
For each objService in colServices
If objService.State = "Stopped" Then
‘* WScript.Echo "Starting: " & objService.DisplayName & "," & _
‘*objService.StartName & "," & objService.State
objService.StartService
End if
Next
End Sub[/code]
In this excample I have installed six services.

6 thoughts on “Multiple NAS Services on a single license

  1. Felicidad says:

    Greetings 😀 Is it okay that I go a bit off topic? I’m trying to read your page on my iPad but it doesn’t display properly, do you have any suggestions? Thanks for the help I hope! Felicidad x 🙂

    1. This is confirmed and has to do with the web page fixed width. Not sure if I can change it with the current theme.

  2. a m says:

    Hi Gunnar, Is this possible to do in 2013 as well, or are different kind of script required there?

    1. Hi

      In NAV 2013 you can start as many NAS services as you need, they don’t require a license.

  3. Alexandros G. Papaspyridis says:

    Gunnar thank you for all your postings. If we have two servers (physical machines) running one nas each other, and both of them are on the same company on the same database, is there anyway to manage the balance between the two NAS servers?
    thanks

    1. Hi Alexandros

      In NAV 2013 R2 Job Queue you can see that NAV is using group code to divide tasks between individual NAS processes. Perhaps by adding a computer name to the job queue and filtering on each NAS.

Leave a Reply

%d bloggers like this: