@echo off
REM ==============================================================
REM RunAgent=Run the agent
REM Version=6.9
REM Environment variables used by this scipt:
REM	ALTIRIS_PROCESSOR    The processor type to use for the agent
REM	ALTIRIS_SHARE        The path to the Deployment Share
REM	_RunAgentRemote      "" to run the local agent, otherwise run the remote agent
REM	_Agent               The path to the agent to run - "" will use the default path
REM	_Agent_cfgpath       Path to the agent config file (default = same as agent)
REM	_Agent_Persistent    Set to tell the agent its settings can be persistent
REM	_Agent_AutoUpdate    Set to tell the agent is can autoupdate itself
REM	_Agent_Lock          The parameters to pass to lock the agent
REM	_Agent_Params        Extra parameters to pass to the agent
REM	_ScreenLock          Set to tell the agent to run in locked mode
REM Most can also be passed as command line parameters in this order:
REM	1 = (Action: Start or Restart)
REM	2 = _RunAgentRemote
REM	3 = ALTIRIS_PROCESSOR
REM	4 = ALTIRIS_SHARE
REM	5 = _Agent_Persistent
REM	6 = _Agent_AutoUpdate
REM	7 = _Agent_Lock
REM	8 = _Agent_Params
REM --------------------------------------------------------------
:RunAgent
setlocal EnableDelayedExpansion EnableExtensions
if not defined log if not defined __log if exist "%systemdrive%\__log__" set __log=%~dpn0.log
if defined log if not defined __log set __log=true& call %0 %* >>"%~dp0%log%" & set __log=& goto :eof
if defined echo (echo on) else if exist "%systemdrive%\__echo__" (echo on) else (echo off)
set __dbg=rem & if defined debug (set __dbg=) else if exist "%systemdrive%\__debug__" (set __dbg=) else (set __dbg=rem)

REM ==============================================================
REM Agent=Start Agent (as detached process)
REM Agent cmdline parameters are:
REM	...
REM Agent environment variables are:
REM	...
REM --------------------------------------------------------------
:Agent
echo.
echo Starting Agent...


rem Prepare to locate and run the agent...


echo Locating Agent...
if not defined _Agent if defined _RunAgentRemote (
  echo.  Searching Deployment Share for Agent...


rem Do whatever is needed to find a remote copy of the agent.
rem Set the _Agent environment variable to the path of the agent to run.
rem The agent files can be copied locally if needed.


)

rem Run the agent

rem Run the agent now.
rem Running the agent must NOT block this script from returning to the startup scripts.
rem If the agent would block this process, then use the "start" command to detach it as a separate process.


:DoneAgent
echo.

endlocal
goto :eof
