In the past weeks, I have been working on a deployment of Dynamics NAV 2018. This is quite a change for me, to work again on a Windows machine, and with closed source software. Fortunately, there are already some resources on the web, eg. Powershell scripts by Waldo: https://github.com/waldo1001/Cloud.Ready.Software.PowerShell/tree/master/PSScripts
Today, I want to publish some basic Batch scripts that help our team to start our development environment. In our setup, we have a normal unprivileged Windows user. But we need a privileged user for access to the Dynamics NAV Server. Lets assume that the privileged user has a suffix called -p for privileged.
This script will just start the Dynamics NAV 2018 client, running as the privileged user.
@echo off runas /user:"MYDOMAIN\%USERNAME%-p" "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe -settings:\\files\ERP\RTCCONFIG\DEV110_NST01_V103.config"
This script will start the Dynamics NAV IDE, which we use mainly for the Object Designer. We need the parameter generatesymbolreference, so that the symbols will be generated when we compile the C/AL code, so that the symbols are available for AL development in VS Code.
It seems we have some issue with localization, some users need Ja (german culture), others need Yes as the value for generatesymbolreference.
@echo off REM runs the Dynamics NAV IDE (Object Designer) REM some users have to use generatesymbolreference=Ja others need generatesymbolreference=Yes REM we try to determine the language settings by the variable HomePath: Users vs Benutzer set "generatesymbolreference=Ja" if "%ProgramFiles%" equ "C:\Program Files" (SET /A generatesymbolreference=Yes) runas /user:"MYDOMAIN\%USERNAME%-p" "C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\finsql.exe generatesymbolreference=%generatesymbolreference%"
This script starts a PowerShell with the right startup parameters, so that some specific modules will be preloaded for development of Dynamics NAV. This seems to be quite tricky, to start PowerShell with another user. So we call the Batch script again as the different user, in order to be able to start PowerShell as that user.
@echo off REM start the DynamicsNAV Development PowerShell SET mypath=%~dp0 echo %mypath% IF "%USERNAME:~-2%" neq "-p" ( runas /user:"MYDOMAIN\%USERNAME%-p" "%mypath%\startDynamicsNAVShell.bat" ) else ( cd C:\Users\%USERNAME%\DEV C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell.exe -NoExit -ExecutionPolicy RemoteSigned " & ' C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\NavModelTools.ps1 ' " )
Last, but not least: we start VSCode as a different user.
@echo off start runas /user:"MYDOMAIN\%USERNAME%-p" "C:\Program Files\Microsoft VS Code\Code.exe"