Sometimes I just want to administer Dynamics AX 2012 R3 from a DOS prompt. The command line tools I use are: axutil, axbuild and some command line startup commands that can be passed when starting the Client application.
I use axutil to import and export, or even delete, models from Dynamics AX 2012 R3. After changing the modelstore, I use axbuild to compile the environment. And to make sure the database is catched up, I start my client application with the option to synchronize the database.
Now for the actions described above I created example batch files. With these batches I can quickly setup a specific Dynamics AX 2012 R3 environment. Use the examples at your own risk!
Create-model.bat
@ECHO OFF
REM Author: byteway
REM Description: Create Dynamics AX Model
SET AXUTIL="c:\\Program Files\\Microsoft Dynamics AX\\60\\Server\\MicrosoftDynamicsAX\\bin\\AXUtil.exe"
SET MODELNAME="%~1"
IF %MODELNAME%=="" GOTO DONOTHING
GOTO DOCREATE
:DOCREATE
%AXUTIL% create /model:"%MODELNAME%" /layer:"USR"
GOTO END
:DONOTHING
ECHO No modelname found!
ECHO Example: "create-model.bat 'TEST'"
GOTO END
:END
pause
Export-model.bat
@ECHO OFF
REM Author: byteway
REM Description: Export Dynamics AX Model
SET AXUTIL="c:\\Program Files\\Microsoft Dynamics AX\\60\\Server\\MicrosoftDynamicsAX\\bin\\AXUtil.exe"
SET MODELNAME=%~1
SET OUTPUTFOLDER=%~2
SET COUNTER=1
IF %MODELNAME%=="" GOTO NOMODELNAME
IF %OUTPUTFOLDER%=="" GOTO NOOUTPUTFOLDER
GOTO LOOPFILENAME
:LOOPFILENAME
if exist "%OUTPUTFOLDER%%MODELNAME%(%COUNTER%).axmodel" set /a COUNTER+=1 && GOTO :LOOPFILENAME
SET OUTPUTFILE="%OUTPUTFOLDER%%MODELNAME%(%COUNTER%).axmodel"
GOTO DOEXPORT
:DOEXPORT
%AXUTIL% export /model:%MODELNAME% /file:%OUTPUTFILE%
GOTO END
:NOMODELNAME
ECHO No modelname found!
ECHO Syntax: export-model.bat "modelname" "output folder"
ECHO Example: "export-model.bat 'TEST' 'c:\Temp\'"
GOTO END
:NOOUTPUTFOLDER
ECHO No output folder found!
ECHO Syntax: export-model.bat "modelname" "output folder"
ECHO Example: "export-model.bat 'TEST' 'c:\\Temp\\'"
GOTO END
:END
pause
Remove-model.bat
@ECHO OFF
REM Author: byteway
REM Description: Delete Dynamics AX Model
SET AXUTIL="c:\\Program Files\\Microsoft Dynamics AX\\60\\Server\\MicrosoftDynamicsAX\\bin\\AXUtil.exe"
SET MODELNAME="%~1"
IF %MODELNAME%=="" GOTO DONOTHING
GOTO DODELETE
:DODELETE
%AXUTIL% delete /model:"%MODELNAME%"
GOTO END
:DONOTHING
ECHO No modelname found!
ECHO Example: "remove-model.bat 'TEST'"
GOTO END
:END
pause
Compile-all.bat
@ECHO OFF
REM Author: byteway
REM Description: Recompile Dynamics AX
SET AXBUILD="c:\\Program Files\\Microsoft Dynamics AX\\60\\Server\\MicrosoftDynamicsAX\\bin\\AXBuild.exe"
REM First restart the Application Object Server
net stop MSSQLSERVER
net stop AOS60$01
net start MSSQLSERVER
net start AOS60$01
REM Second start compilation threads
cd "c:\\Program Files\\Microsoft Dynamics AX\\60\\Server\\MicrosoftDynamicsAX\\bin\\"
%AXBUILD% xppcompileall /workers=8 /s=01
pause
Synchronize.bat
@ECHO OFF
REM Author: byteway
REM Description: Synchronize the Dynamics AX database
SET AX32="c:\\Program Files (x86)\\Microsoft Dynamics AX\\60\\Client\\Bin\\Ax32.exe"
REM Synchronize the DB
%AX32% -lazyclassloading -lazytableloading -StartupCmd=Synchronize
pause