Tuesday, May 22, 2018

Dynamics NAV - How to Automatically restart a NAS instance using Batch file or SQL

Create a new batch file with these lines
Replace YourServerInstanceName with the specific instance you want to restart (It should be your NAS instance from the NAV Admin tool)
-----------------------------------------------

NET STOP "MicrosoftDynamicsNavServer$YourServerInstanceName"
NET START "MicrosoftDynamicsNavServer$YourServerInstanceName"

------------------------------------------------

Schedule this batch file to run daily with admin priveleges to ensure you always have a clean NAS running.
ensure that the scheduling does NOT interfere with any jobs like adjust costs, otherwise it will kill the job halfway.


---------------------------------------------
This can also be done using SQL

-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1; GO -- To update the currently configured value for advanced options. RECONFIGURE; GO -- To enable the feature. EXEC sp_configure 'xp_cmdshell', 1; GO -- To update the currently configured value for this feature. RECONFIGURE; GO
xp_cmdshell 'NET STOP MicrosoftDynamicsNavServer$YourServerInstanceName'

xp_cmdshell 'NET START MicrosoftDynamicsNavServer$YourServerInstanceName'

No comments:

Post a Comment