AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 09.03.2007, 14:50   #1  
Blog bot is offline
Blog bot
Участник
 
25,584 / 848 (80) +++++++
Регистрация: 28.10.2006
axaptapedia: Control AOS from command line
Источник: http://www.axaptapedia.com/Control_A...m_command_line
==============

Summary: new article - aos control from command line
==Controlling the AOS from the command line==

When automating backups, restores, testing etc, it is often useful to be able to control the stopping and starting of the Dynamics AX 4.0 AOS services from a batch file or DOS prompt.

These two simple DOS batch files allow you to do so, and wait for the action to complete before returning control to the caller.

===Starting the AOS===

''Takes two parameters, %1 == server name (with slashes, e.g. \SVR01), %2 = AOS name (the actual service name, which is reality is AOS$01, AOS$02 and so on)''

Filename:

startAOSWait.bat

Contents:

@echo off

REM %1 is server name with slashes, %2 is service name

REM Try to start service
sc.exe %1 start %2 | FIND "FAILED"
IF NOT ERRORLEVEL 1 GOTO ENDCHECK

REM Loop until service is started or max counter is reached
SET /a COUNT = 1

:LOOP1
sc %1 query %2 | FIND "STATE" | FIND "RUNNING"
IF NOT ERRORLEVEL 1 GOTO ENDOK

REM ** Running **
SET /a COUNT=COUNT+1
IF %COUNT% GEQ 1000 GOTO ENDFAILED
GOTO LOOP1

:ENDCHECK
REM ** Start failed, but maybe already running so check
sc %1 query %2 | FIND "STATE" | FIND "RUNNING"
IF NOT ERRORLEVEL 1 GOTO ENDOK
GOTO ENDFAILED

:ENDOK
REM ** Started OK so exist with errorlevel 0**
ECHO STARTED OK
EXIT /B 0

:ENDFAILED:
REM ** Failed to start so exist with errorlevel 1**
ECHO STARTING FAILED
EXIT /B 1

This script will set an error level of 0 if the service was already running, or successfully started, and an error level of 1 otherwise.
'
===Stopping the AOS===

''Takes two parameters, %1 = server name (with slashes, e.g. \SVR01), %2 = AOS name (the actual service name, which is in the format of AOS$01, AOS$02 and so on)''

Filename:

stopAOSWait.bat

Contents:

@echo off

REM %1 is server name with slashes, %2 is service name

REM Try to stop service
sc.exe %1 stop %2 | FIND "FAILED"
IF NOT ERRORLEVEL 1 GOTO ENDCHECK

REM Loop until service is stopped or 30000 counter is reached
SET /a COUNT = 1

:LOOP1
sc %1 query %2 | FIND "STATE" | FIND "STOPPED"
IF NOT ERRORLEVEL 1 GOTO ENDOK

REM ** Running **
SET /a COUNT=COUNT+1
IF %COUNT% GEQ 1000 GOTO ENDFAILED
GOTO LOOP1

:ENDCHECK
REM ** Stop failed, but maybe already stopped so check
sc %1 query %2 | FIND "STATE" | FIND "STOPPED"
IF NOT ERRORLEVEL 1 GOTO ENDOK
GOTO ENDFAILED

:ENDOK
REM ** Stopped OK so exist with errorlevel 0**
ECHO STOPPED OK
EXIT /B 0

:ENDFAILED:
REM ** Failed to stop so exist with errorlevel 1**
ECHO STOP FAILED
EXIT /B 1

This script will set an error level of 0 if the service was already stopped, or was successfully stopped, and an error level of 1 otherwise.

===Running the scripts===

These scripts can be run stand-alone, or from another batch file. If you call them from another batch file then you should use the "call" syntax to do so.

call stopAOSWait.bat \AXAPTA01 AOS$01

REM Do something here like copying application files, restoring a database etc

call startAOSWait.bat \AXAPTA01 AOS$01


Источник: http://www.axaptapedia.com/Control_A...m_command_line
За это сообщение автора поблагодарили: Logger (1).
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
palleagermark: Channel 9 video: Dynamics AX Version Control interview from Convergence in Copenhagen 2008 Blog bot DAX Blogs 0 30.01.2009 16:05
axaptapedia: Create New AOT Project From Template Blog bot DAX Blogs 0 29.08.2008 21:10
Khue Trinh: AX 2009 Quality Management - Quality Control Blog bot DAX Blogs 1 04.07.2008 16:01
epblog: How to update Data Set from User Control? Blog bot DAX Blogs 0 21.06.2008 13:05
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 23:47.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.