@Echo off

REM  set path=V:\JobManager\ProgEntw\Ver02\JobManagerV2\03-BinPublic;%Path%
REM  call :Wait 5 "my Info"
REM  pause
REM  exit
 setlocal EnableDelayedExpansion EnableExtensions
 rem ---------------------------------------------------------
 rem JobManager V2 Generic Script
 rem (c) J.Feuerstein 24.11.2006
 rem
 rem Aenderungs Info:
 rem User    Date/Time (Shift+strg+T)  Infotext:
 rem J.Fes   24.11.2006 00:05:59       Ersterstellung 24.11.2006
 rem ---------------------------------------------------------
 rem Variablen ersetzungs Abschnitt
 rem Info die mit "#" Gitter eingeschlossenen Vaiablen werden vom JobServer
 rem vor dem senden an den JobClient ersetzt

 rem Debug: [bei Einzel Test's auf=ON] [sonst auf OFF stellen]
 set JobMgr_Debug=OFF
 set JobMgr_Test=OFF

 rem wird im JobScript angegben so wird der File:[#JobName#_ObjectsList.txt] nicht dem JobFile hinzugefuegt.
 set JobAddFile_ObjectsList_txt=true
 rem wird im JobScript angegben so wird der File:[#JobName#_ObjectsListAllDetails.txt] nicht dem JobFile hinzugefuegt.
 set JobAddFile_ObjectsListAllDetails_txt=true
 rem wird im JobScript angegben so wird der File:[JobData1ToProcess_XML] nicht dem JobFile hinzugefuegt.
 set JobAddFile_JobData1ToProcess_xml=true

 rem -- JobScriptParametersExtended:
 rem    Hinweis:"JobScriptParametersExtended" ist nach dem ausfueller der # variablen dann leer
 rem             wenn das Datenfeld von Script/Param. J.Cmd.ParmExt leer
 #JobScriptParametersExtended#

 rem -- am Anfang Farbe auf IsIdel setzen
 call :ColorSet IsIdel

 rem Standard Path Variablen
 set BinServer_DP=#01-BinServer_DP#
 set BinClient_DP=#02-BinClient_DP#
 set BinPublic_DP=#03-BinPublic_DP#
 set JobScripts_DP=#10-JobScripts_DP#
 set MyApplName_TP=#MyApplName_TP#

 set Editor_DPNE=%BinPublic_DP%\PSPad editor\PSPad.exe

 rem JobParameter
 set JobName=#JobName#
 set JobParameter=#JobParameter#
 set JobObjectsPacket_NE=#JobObjectsPacket_NE#
 set JobObjectsPacketAllDetails_NE=#JobObjectsPacketAllDetails_NE#
 rem Root Verzeichniss der Scriptvorlage
 set JobScriptTemplateMinus1_DP=#JobScriptTemplateMinus1_DP#
 set JobScriptTemplate_DP=#JobScriptTemplate_DP#

 rem TC Daten
 set TcSiteId=#TcSiteId#

 set CmdCur_Title=#JobName#
 set JobMgr_TcUser=%1
 set JobMgr_TcPw=%2

 rem Übergabe der JobPlaner Parameter
 rem   Hinweis: wurde eine #Variable nicht uebergeben so kann über die folgende Beispiel Zeile geprüft werden.
 rem            Beispiel: if "%JobPlaner_Owner:~1,-1%"=="JobPlaner_Owner" set JobPlaner_Owner=
 set JobPlaner_Owner=#JobPlaner_Owner#
 if "%JobPlaner_Owner:~1,-1%"=="JobPlaner_Owner" set JobPlaner_Owner=
 set JobPlaner_Param=#JobPlaner_Param#
 if "%JobPlaner_Param:~1,-1%"=="JobPlaner_Param" set JobPlaner_Param=

 rem Example für eine Umgebungsvariable die über den JobPlaner weitergereicht wurde
 set JobPlanerEnv_Path=#JobPlanerEnv_PATH#
 set JobPlanerEnv_Username=#JobPlanerEnv_USERNAME#
 set JobPlanerEnv_ComputerName=#JobPlanerEnv_COMPUTERNAME#

 rem Verweist auf den JobLogZipArchive File new 05.04.2012 11:54
 set JobLogZipArchiv_DPNE=#JobLogZipArchiv_DPNE#

 rem ---------------------------------------------------------------------------
 if /i "%JobMgr_Test%" equ "ON" (
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
   Banner Test:ON
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
 )
 if "%JobMgr_Debug%"=="ON" (
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
   Banner Debug:ON
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
 )

 rem ---------------------------------------------------------------------------
 rem Rootpfade setzen
 set CmdCur_DPNE=%~0
 set CmdCurRoot_DP=%~dp0
 set CmdCurRoot_DP=%CmdCurRoot_DP:~0,-1%
 set path=%CmdCurRoot_DP%;%Path%

 rem temp dir Organiesieren
 set temp_DP_org=%temp%
 set temp=%CmdCurRoot_DP%\JobTemp
 if not exist "%temp%" md "%temp%"
 cd /d "%temp%"

 rem ---------------------------------------------------------------------------
 rem -- PaketFile festlegen
 set JobObjectsPacket_DPNE=%CmdCurRoot_DP%\%JobObjectsPacket_NE%
 set JobObjectsPacketAllDetails_DPNE=%CmdCurRoot_DP%\%JobObjectsPacketAllDetails_NE%

:StartJobProcessing
 call :ColorSet IsExecuting
 set JobTimeStart=%Date% %time:~0,8%
 set title_str=Job:[%JobName%] [%TcSiteId%] [Start:%JobTimeStart%] [\\%ComputerName%] [%JobMgr_TcUser%]
 title %title_str%
 Echo %title_str%
 Echo --------------------------------------------------------------------------
 Echo Job Info:
 Echo JobName.............: %JobName%
 Echo Computer............: %ComputerName%
 Echo TempDir.............: %temp%
 Echo TcSide..............: %TcSiteId%
 Echo TcUser..............: %JobMgr_TcUser%
 Echo Job Parameter.......:
 Call :JobParam_List "%JobParameter%"
 Echo Start...............: %JobTimeStart%
 Echo.
 
 if /I "%JobMgr_Debug%"=="ON" (
  Echo #Debug: Start Explorer at JobDir:[%CmdCurRoot_DP%]
  start "" Explorer "%CmdCurRoot_DP%"
  pause
 )
 rem #Debug :Wait 2 entfernen
 rem Call :Wait 2

 set Custom01_Cmd_DPNE=%CmdCurRoot_DP%\Custom01.cmd
 if exist "%Custom01_Cmd_DPNE%" Call "%Custom01_Cmd_DPNE%"

 Echo --------------------------------------------------------------------------
 Echo List of Objects to process in this Job:
 set ObjectsNtoProcess=0
 FOR /F "skip=1 delims=" %%i in (%JobObjectsPacketAllDetails_DPNE%) do call :ObjectsCount "%%i"
 set ObjectNr=0
 FOR /F "skip=1 delims=" %%i in (%JobObjectsPacketAllDetails_DPNE%) do call :ObjectToProcessInfo "%%i"
 Echo --------------------------------------------------------------------------
 set ObjectNr=0
 FOR /F "skip=1 delims=" %%i in (%JobObjectsPacketAllDetails_DPNE%) do call :RunCommandsOnObjects "%%i"

 set JobTimeEnd=%Date% %time:~0,8%
 Echo.
 Echo --------------------------------------------------------------------------
 Echo End.................: %JobTimeEnd%


 if "%JobMgr_Debug%"=="ON" (
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
   Echo #Debug Info: Ende
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
   pause
 )
 if /i "%JobMgr_Test%" equ "ON" (
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
   Banner #Test:End
   Echo ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  ----  --
   pause
 )


 rem -- Farbe auf JobEnds setzen
 call :ColorSet End

 goto :end

rem ----------------------------------------------------------------------------
:RunCommandsOnObjects
 rem Farbe auf JobColorJobIsExecuting setzen
 call :ColorSet IsExecuting
 set /A ObjectNr=%ObjectNr%+1

 call :DataSetSplit %1

 rem print the JobDetails
 Echo --------------------------------------------------------------------------
 Echo JobProcess Details:
 Echo ObjectNr...............: %ObjectNr%/%ObjectsNtoProcess%
 Echo ObjectCliName..........: %ObjectCliName%
 Echo ObjectCliNameForFileSys: %ObjectCliNameForFileSys%
 Echo Group..................: %ObjectGroup%
 Echo O.Type SP/AP...........: %ObjectUgMaster_Type%/%ObjectUgMaster_APLevels%/%ObjectUgMaster_CompCount%
 Echo O.Volume...............: %ObjectFs_Volume%
 Echo O.Fs_DPNE..............: %ObjectFs_DPNE%
 Echo O.Fs_NE................: %ObjectFs_NE%

 if "%JobMgr_Debug%"=="ON" (
  Echo #Debug:
  pause
 )

 rem ... do the JobWith the Object
 rem ... ...
 rem und write your Logfile
 rem # Debug entfernen
 rem 1. Ergebnis = OK 2. Ergebniss = Err da >0
 rem set /A ResCode=%ObjectNr%-1
 rem 1. Ergebnis = OK 2. Ergebniss = Err da <0
 set /A ResCode=%ObjectNr%-1

 call :JobResultsGenericV1_WriteLog  "%ObjectCliName%" "%ResCode%" "Result:O.Group:[%ObjectGroup%] O.Typ:[%ObjectUgMaster_Type%/%ObjectUgMaster_APLevels%/%ObjectUgMaster_CompCount%] P.JobPlaner_Owner:[%JobPlaner_Owner%]" "%JobParameter%"

 rem -- Farbe auf Idel setzen
 Call :ColorSet Idel
 rem pause
 goto :eof


rem #### ------------ Standard Subroutines --------------------- ######
rem ============================================================================
:JobParam_List
 setlocal
  set JobParams=%~1
  set NCur=0
 :JobParam_List_PrintNext
  set /a NCur=%NCur%+1
  FOR /F "tokens=%NCur% delims=-" %%i IN ("%JobParams%") do Call :JobParam_Print "%%i"
  if %NCur% LEQ 10 goto :JobParam_List_PrintNext
 endlocal
 goto :eof

:JobParam_Print
 setlocal
  set JobParaCur=%~1
  if not "%JobParaCur%"=="" Echo                     : -%JobParaCur%
 endlocal
 goto :eof

rem ============================================================================
:JobResultsGenericV1_WriteLog
 setlocal
   rem schreibt einen Generic JobProcessResultLog_DPNE Logfile
   rem Festlegung: der Seperator muss immer: #;# sein
   rem die Ergebniszeilen sind aufgebaut nach folgenden Schema:
   rem ObjectNamedId#;#ResultCode#;#ResultMsg
   rem P1 = ObjectNamedId
   rem P2 = ResultCode
   rem P3 = ResultMsg
   rem P4 = Process Options
   rem P5 = has Warings
   rem P6 = JobLink

   rem festlegen des JobProcessResultLog_DPNE Filenamen
   rem Hinweis: der File muss enden mit  _GenericJobResultsV1.Log
   set JobProcessResultLog_DPNE=%temp%\_%JobName%_JobResultsGenericV1.Log
   rem P1+P2 mit strip "
   set P1=%~1
   set P2=%~2
   rem P3+P4 verbleiben wie original uebergeben
   set P3=%3
   set P4=%4
   set P5=%5
   set P6=%6
   rem P7 erhält alle JobServerExtendCommandsTrigger
   rem Bspl.:
   rem /ProcessStateSetTo=D.NX4
   rem /CB_DataFile1_DPNE="\\jf-18\JobManagerV2_Data\CheckBoxData\BgStrukEx_Einzelteil_01_01_RevA\BgStrukEx-Einzelteil-01_01_A_master_NX4.XML"
   rem /CB_DataFile2_DPNE="\\jf-18\JobManagerV2_Data\CheckBoxData\BgStrukEx_Einzelteil_01_01_RevA\BgStrukEx-Einzelteil-01_01_A_master_NX6.XML"
   set P7=%7

   rem -- schreibt das Ergebniss in die Datei
   Echo %P1%#;#%P2%#;#%P3%#;#%P4%#;#%P5%#;#%P6%#;#%P7%>>%JobProcessResultLog_DPNE%
   if     "%P2%"=="0" goto :JobResultsGenericV1_WriteLog_exitOk
   if not "%P2%"=="0" goto :JobResultsGenericV1_WriteLog_exitErr

   :JobResultsGenericV1_WriteLog_exitOk
    rem - set color Ok
    Call :ColorSet Ok
    call :PrintResultMsg "OK" "[OK] Code=[%P2%] CLI=[%P1%]"
                  Echo        MSG=[%P3%] Opt=[%P4%]
    goto :JobResultsGenericV1_WriteLog_myExit

   :JobResultsGenericV1_WriteLog_exitErr
    rem - set color Err
    Call :ColorSet Err
    call :PrintResultMsg "ERR:%P2%" "[ERR] Code=[%P2%] CLI=[%P1%]"
                    Echo        MSG=[%P3%] Opt=[%P4%]
    goto :JobResultsGenericV1_WriteLog_myExit

   :JobResultsGenericV1_WriteLog_myExit

 endlocal
 rem call :Wait 1
 goto :eof

rem ============================================================================
:PrintResultMsg
 rem Ausgabe des aktuellen Ergebnisses
 rem P1 = AktionInfo
 setlocal
   set timePrint=%Time:~0,5%
   set timePrint=%timePrint: =0%
   Set CurrInfo=%2 [%Date:~0,6%%Date:~8,2% %timePrint% %JobName%]
   Title %CmdCur_Title% Result:%CurrInfo%
   Banner.exe "%1"
   Echo Result:%CurrInfo%
 endlocal
 goto :eof

rem ============================================================================
:ObjectsCount
 rem hochzählen des Anzahlzählers
 set /A ObjectsNtoProcess=%ObjectsNtoProcess%+1
 goto :eof
rem ============================================================================
:ObjectToProcessInfo
REM  Call :ObjectsCount
 set /A ObjectN=%ObjectN%+1
 call :DataSetSplit %1

 if "%ObjectN%"=="1" (
 Echo Num:   Typ/Lev/Comp Dataset
REM   rem print Header
REM      if "%ObjectsNtoProcess%" LEQ "9" (
REM      Echo Num:   Item-Revision:                      UgMTyp/Lev/Comp
REM   ) else (
REM      if "%ObjectsNtoProcess%" LEQ "99" (
REM      Echo Num:    Item-Revision:                     UgMTyp/Lev/Comp
REM      ) else (
REM      Echo Num:     Item-Revision:                    UgMTyp/Lev/Comp
REM             )
REM          )
 )
 set ObjectNPrint=00%ObjectN%
 set ObjectNPrint=%ObjectNPrint:~-2,2%
 set IrNamePrint=[%IrName%]???????????????????????????????????????????
 set Typ_Lev_Comp=[%ObjectUgMaster_Type%/%ObjectUgMaster_APLevels%/%ObjectUgMaster_CompCount%]???????????????????????????????????????????
 set Typ_Lev_Comp_Print=%Typ_Lev_Comp:~0,12%
 rem ersetzen ? durch " " (Blank)
 set Typ_Lev_Comp_Print=%Typ_Lev_Comp_Print:?= %

 rem 30 Zeichen lang
 set IrNamePrint=%IrNamePrint:~0,35%
 rem ersetzen ? durch " " (Blank)
 set IrNamePrint=%IrNamePrint:?= %

REM  Echo [%ObjectNPrint%/%ObjectsNtoProcess%] %IrNamePrint% %ObjectUgMaster_Type%/%ObjectUgMaster_APLevels%/%ObjectUgMaster_CompCount%
 Echo [%ObjectNPrint%/%ObjectsNtoProcess%] %Typ_Lev_Comp_Print% %ObjectCliName%
 goto :eof


rem ============================================================================
:ColorSet
 rem -- cmd Color Farbinfo:
 REM    0 = Schwarz        8 = Dunkelgrau
 REM    1 = Dunkelblau     9 = Blau
 REM    2 = Dunkelgrün     A = Grün
 REM    3 = Blaugrün       B = Zyan
 REM    4 = Dunkelrot      C = Rot
 REM    5 = Lila           D = Magenta
 REM    6 = Ocker          E = Gelb
 REM    7 = Hellgrau       F = Weiß

 rem -- Farben nach Status setzen
 rem Gelb Schwarz
 if /I "%1"=="IsExecuting" set JobColorLast=E0
 rem Blaugrün Schwarz
 if /I "%1"=="IsIdel"      set JobColorLast=30
 rem Hellgrau Schwarz
 if /I "%1"=="End"         set JobColorLast=70
 if /I "%1"=="Ende"        set JobColorLast=70
 rem Gruen Schwarz
 if /I "%1"=="Ok"          set JobColorLast=A0
 rem Rot Schwarz
 if /I "%1"=="Err"         set JobColorLast=C0

 rem jetzt die Farbe setzen
 if not "%JobColorLast%"=="" color %JobColorLast%
 goto :eof

rem ============================================================================
:DataSetSplit
 rem Splittet einen JobMgr AllDetails Datensatzes auf

 rem vorne und hinten " abscheiden
 set ObjectInfoLine01=%~1
REM  set ObjectInfoLine01=%ObjectInfoLine01:~1,-1%

REM  ItemName-C01;RevName-C02;IrName-C03;IrCliName-C04;ObjectCliNameForFileSys-C05;ObjectName-C06;ObjectFromSiteID-C07;ObjectClass-C08;ObjectType-C09;ObjectCliName-C10;ObjectOwningSiteID-C11;ObjectOwner-C12;ObjectGroup-C13;ObjectCreateDate-C14;ObjectLastModUser-C15;ObjectLastModDate-C16;ObjectUgMaster_Type-C17;ObjectUgMaster_CompCount-C18;ObjectUgMaster_APLevels-C19;ObjectUgMaster_FsHitCount-C20;ObjectFs_DPNE-C21;ObjectFs_Vol-C22;ObjectFs_NE-C23;ObjectUgMaster_PartFamMemName-C24;ObjectNote-C25;ObjectSelectByMarker-C26;reservation1-C27;reservation2-C28;reservation3-C29;reservation4-C30;reservation5-C31;ID-C32;ProcStateCol01-C33;ProcStateCol02-C34;ProcStateCol03-C35;ProcStateCol04-C36;ProcStateCol05-C37;ProcStateCol06-C38;ProcStateCol07-C39;ProcStateCol08-C40;ProcStateCol09-C41;ProcStateCol10-C42;ObjectAttr01-C43;ObjectAttr02-C44;ObjectAttr03-C45;ObjectAttr04-C46;ObjectAttr05-C47;ObjectAttr06-C48;ObjectAttr07-C49;ObjectAttr08-C50;ObjectAttr09-C51;ObjectAttr10-C52


 rem Objektdaten extrahieren nach dem 31 ";"
 FOR /F "tokens=31,* delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectInfoLine32=%%j

 FOR /F "tokens=1 delims=;"  %%i IN ("%ObjectInfoLine01%") do set ItemName=%%i
 FOR /F "tokens=2 delims=;"  %%i IN ("%ObjectInfoLine01%") do set RevName=%%i
 set Ir=%ItemName%/%RevName%

 FOR /F "tokens=3 delims=;"  %%i IN ("%ObjectInfoLine01%") do set IrName=%%i
 FOR /F "tokens=4 delims=;"  %%i IN ("%ObjectInfoLine01%") do set IrCli=%%i

 FOR /F "tokens=5 delims=;"  %%i IN ("%ObjectInfoLine01%") do set ObjectCliNameForFileSys=%%i
 FOR /F "tokens=6 delims=;"  %%i IN ("%ObjectInfoLine01%") do set ObjectName=%%i
 FOR /F "tokens=7 delims=;"  %%i IN ("%ObjectInfoLine01%") do set ObjectFromSiteID=%%i

 FOR /F "tokens=9 delims=;"  %%i IN ("%ObjectInfoLine01%") do set ObjectType=%%i
 FOR /F "tokens=10 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectCliName=%%i
 rem rebuild semicolon via replace "#Chr(59)#" to ";"
 set ObjectCliName=%ObjectCliName:#Chr(59)#=;%

 FOR /F "tokens=12 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectOwner=%%i
 FOR /F "tokens=13 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectGroup=%%i
 FOR /F "tokens=15 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectLastModUser=%%i

 rem ObjectUgMaster_Type = Sp/Ap
 FOR /F "tokens=17 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectUgMaster_Type=%%i
 FOR /F "tokens=18 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectUgMaster_CompCount=%%i
 FOR /F "tokens=19 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectUgMaster_APLevels=%%i

 FOR /F "tokens=21 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectFs_DPNE=%%i
 FOR /F "tokens=22 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectFs_Volume=%%i
 FOR /F "tokens=23 delims=;" %%i IN ("%ObjectInfoLine01%") do set ObjectFs_NE=%%i

REM  ObjectFs_DPNE-C21;ObjectFs_Vol-C22;ObjectFs_NE-C23;ObjectUgMaster_PartFamMemName-C24

 Rem Special Variablen ..NoBlanks
 set ItemNameNoBlanks=%ItemName: =%
 call :ReplaceInvalidChar ItemNameNoBlanks "%ItemNameNoBlanks%"
 set RevNameNoBlanks=%RevName: =%
 call :ReplaceInvalidChar RevNameNoBlanks "%RevNameNoBlanks%"

 if /I "%2"=="Print" call :DataSetCurrPrint
 goto :eof

rem ============================================================================
:ObjectCliName_use_parse
  rem ermittelt den zu verwendenden CLiNamen bei UGMaster = %IrCli%
  set ObjectCliName_use=%ObjectCliName%
  if "%ObjectType%"=="UGMASTER" set ObjectCliName_use=%IrCli%
 goto :eof
rem ============================================================================
:DataSetCurrPrint
 Echo IrCli            : %IrCli%
 Echo ItemName         : %ItemName%
 Echo RevName          : %RevName%
 Echo ObjectCliName    : %ObjectCliName%
 Echo ItemNameNoBlanks : %ItemNameNoBlanks%
 Echo RevNameNoBlanks  : %RevNameNoBlanks%
 goto :eof

rem ============================================================================
:GenCmdRunAfterImportOnJobServer
 rem erzeut ein RunAfterImportOnJobServer.cmd
 set P1=%1
 set P1=%P1:"=%
 set P2=%2
 set P2=%P2:"=%
 set P3=%3
 set P3=%P3:"=%
 set P4=%4
 set P4=%P4:"=%
 Echo P1=%P1%
 Echo P2=%P2%
 rem set RunAfterImportOnJobServer_DPNE=%temp%\_%JobName%_RunAfterImportOnJobServer.cmd
 set RunAfterImportOnJobServer_DPNE=%temp%\_RunAfterImportOnJobServer.cmd
 Echo @Echo off>>"%RunAfterImportOnJobServer_DPNE%"
 Echo Echo -------- %Date% %time% --------->>"%RunAfterImportOnJobServer_DPNE%"
 Echo Echo ObjectCliName=%P1%>>"%RunAfterImportOnJobServer_DPNE%"
 Echo Echo ResultCode=%P2%>>"%RunAfterImportOnJobServer_DPNE%"

 Echo Pause>>"%RunAfterImportOnJobServer_DPNE%"
 goto :eof

rem ============================================================================
:TcPromtCmdError
 Call :ColorSet Err
 set ErrLog_DPNE=%temp%\__Err_MissingTcePromtCmd_DeaktivateComputer.txt
 set title_str=ERR: !! cannot start JobProcess on:\\%ComputerName% missing TCEPromptCmd [%Date%/%time:~0,8%] !!
 title %title_str%
 Echo --------------------------------------------------------------------------
 rem call :ErrLogHeaderWrite
 Echo %title_str%>>"%ErrLog_DPNE%"
 Echo TCEPromtCmd:=%TCEPromtCmd%>>"%ErrLog_DPNE%"

 Type "%ErrLog_DPNE%"
 rem call :ErrLogFooterWrite
 Echo.
 Echo after press enter you will see the error reason in notepad editor ....
 pause
 start " " Notepad.exe "%ErrLog_DPNE%"
 pause
 goto :end

rem ============================================================================
:Wait
 set waitTime=2
 if not "%1"=="" set waitTime=%~1
 Wait.exe %waitTime% ESC "wait:[%waitTime%] or push 'ESC'-key to continue"
REM  CHOICE /C:w /N /T:w,%waitTime% warte %waitTime% [sec] oder "w" fuer weiter druecken.
 goto :eof

rem ============================================================================
:Echo
 rem Echos Text auf die Console und in eine Datei (wenn angegeben)
 rem Call :Echo "Result Message.........: %JobResMsg%"   "%CmdLog_DPNE%" "%MailCmd_Protokoll_DPNE%"
 rem Example: ohne ausgabe in TracAc
 rem Call :Echo "Result Message.........: %JobResMsg%"   "" ""  "TracAcNo"
 rem Stand V2 30.05.2011 08:12
 setlocal
   rem - TextToEcho erstellen
   set TextToEcho=%~1
   if "%TextToEcho%" equ ""  set TextToEcho=.
   if "%TextToEcho%" neq "." set TextToEcho= %TextToEcho%

   rem - Ausgabe in File
   if "%~2" neq "" (
    Echo!TextToEcho! >>"%~2"
   )

   if "%~3" neq "" (
    Echo!TextToEcho! >>"%~3"
   )

   rem - Ausgabe Console
   Echo%TextToEcho%

   rem - Ausgabe in :TracAc
   if /I "%~4" neq "TracAcNo" if "%TextToEcho%" neq "." call :TracAc "%TextToEcho%"

 :EchoEnd
 endlocal
 goto :eof

rem ============================================================================
:ReplaceInvalidChar
 setlocal
  rem entfernt alle unzulaessigen Zeichen
  set ReplaceInvalidChar=%~2
REM   set ReplaceInvalidChar=%ReplaceInvalidChar:~1,-1%
  set ReplaceInvalidChar=%ReplaceInvalidChar:-=_%
  rem \ durch _ ersetzen
  set ReplaceInvalidChar=%ReplaceInvalidChar:\=_%
  rem / durch _ ersetzen
  set ReplaceInvalidChar=%ReplaceInvalidChar:/=_%
  rem . durch _ ersetzen
  set ReplaceInvalidChar=%ReplaceInvalidChar:.=_%
  rem " " durch _ ersetzen
  set ReplaceInvalidChar=%ReplaceInvalidChar: =_%
  rem "-" durch _ ersetzen
  set ReplaceInvalidChar=%ReplaceInvalidChar:-=_%
  rem "*" durch _ ersetzen
  set ReplaceInvalidChar=%ReplaceInvalidChar:^*=_%
  rem Echo VarName %1 Wert %2 wird zu %ReplaceInvalidChar%
  rem Echo ReplaceInvalidChar=%ReplaceInvalidChar%
  rem pause
 endlocal& set %1=%ReplaceInvalidChar%
 goto :eof

rem ============================================================================
:TypeFile
  rem Types the description and the contens of a file
  setlocal
  set FileToType_DPNE=%1
  set FileToType_DPNE=%FileToType_DPNE:"=%
  set FileDescription=%2
  set FileDescription=%FileDescription:"=%
  Echo Description    : %FileDescription%
  Echo Contens of File: %FileToType_DPNE%
  type "%FileToType_DPNE%"
  endlocal
 goto :eof

rem ============================================================================
:Parse_ALL
 rem parst alle File Bezeichner aus
 rem "\" abschneiden
 set Parse_all$temp=%~dp1
 set Parse_all$temp=%Parse_all$temp:~0,-1%
 set %2_DP=%Parse_all$temp%
 set %2_D=%~d1
 rem "\" hinten und vorne abschneiden
 set Parse_all$temp=%~p1
 set Parse_all$temp=%Parse_all$temp:~1,-1%
 set %2_P=%Parse_all$temp%
 set %2_NE=%~nx1
 set %2_N=%~n1
 set %2_E=%~x1
 set %2_DPNE=%1
 set %2_DPN=%~dpn1
 set Parse_all$temp=
goto :eof

rem ============================================================================
:TracAc
 rem example: Call :TracAc "%0 [MyInfo XYZ]"
 setlocal

 set P1=%~1
 set P2=%~2
 set P3=%~3
 set P4=%~4
 set P5=%~5
 set P6=%~6
 set P7=%~7
 set P8=%~8
 set P9=%~9
 if DEFINED P1 Echo %date% %time:~0,8% %P1%>>"%TracAc_DPNE%"
 if DEFINED P2 Echo %date% %time:~0,8% %P2%>>"%TracAc_DPNE%"
 if DEFINED P3 Echo %date% %time:~0,8% %P3%>>"%TracAc_DPNE%"
 if DEFINED P4 Echo %date% %time:~0,8% %P4%>>"%TracAc_DPNE%"
 if DEFINED P5 Echo %date% %time:~0,8% %P5%>>"%TracAc_DPNE%"
 if DEFINED P6 Echo %date% %time:~0,8% %P6%>>"%TracAc_DPNE%"
 if DEFINED P7 Echo %date% %time:~0,8% %P7%>>"%TracAc_DPNE%"
 if DEFINED P8 Echo %date% %time:~0,8% %P8%>>"%TracAc_DPNE%"
 if DEFINED P9 Echo %date% %time:~0,8% %P9%>>"%TracAc_DPNE%"
 endlocal
 goto :eof



rem ============================================================================
:end
 cd /d "%temp_DP_org%"
 Echo --------------------------------------------------------------------------
 Echo Info: all files in: [%temp%]
 Echo       will be zipt by JobClient and send to JobServer
 rem -- farbe wieder auf standard zurueck setzen
 Call :ColorSet End
