@Echo Off
setlocal EnableDelayedExpansion EnableExtensions

 rem 01.02.2011 J.Fes  Ersterstellung
 rem
 rem Example: Call RefileClientPatchCheck.cmd PatchOK PrintResult
 rem Var: PatchOk returns Status of PatchCheckResult
 rem wenn P2 einen Wert hat z.B. PrintResult dann erfolgt eine ausgabe
 Color E0
 rem Patch Source
 set Patch_S_DP=%~dp0
 set Patch_S_DP=%Patch_S_DP:~0,-1%
 set CmdCurRoot_DP=%Patch_S_DP%
 call :GetFull_DP BinPublic_DP "%Patch_S_DP%\..\..\..\..\..\03-BinPublic"
 set path=%BinPublic_DP%;%Path%

 rem Patch Destination Path for TC:
 set Patch_D_Tc_DP=C:\UG\TC\cax_d\client\bin
 rem Patch Destination Path for NX:
 set Patch_D_Nx_DP=C:\UG\UGNX6
 rem wenn kein Parameter gegben dann path erweitern
 if "%1" equ "" set path=%Patch_D_Nx_DP%\ugii;%Patch_D_Tc_DP%;%Path%
 set PrintResultDO=%2
 if not defined PrintResultDO set PrintResultDO=PrintYes

 if /I "%PrintResultDO:~-3,3%" equ "YES" (
   Echo ------------------------------------------------------------------------
   Echo ClientPatchCheck for.: \\%ComputerName%
  )
REM   erstellt die LibCheck Datei
REM   set InfoVer_DPNE=%CmdCurRoot_DP%\RefilClientePatchInfo.txt
REM   del "%InfoVer_DPNE%"
REM   call :RefileClientPatchSaveInfo "%Patch_D_Nx_DP%\ugii\ugraf.exe"   "#Patch_D_Nx_DP#\ugii\ugraf.exe"   ugraf_exe
REM   call :RefileClientPatchSaveInfo "%Patch_D_Nx_DP%\ugii\libsyss.dll" "#Patch_D_Nx_DP#\ugii\libsyss.dll" libsyss_dll
REM   call :RefileClientPatchSaveInfo "%Patch_D_Tc_DP%\libnxmgr_im.dll"  "#Patch_D_Tc_DP#\libnxmgr_im.dll"  libnxmgr_im_dll
REM   call :RefileClientPatchSaveInfo "%Patch_D_Tc_DP%\tc_service.exe"   "#Patch_D_Tc_DP#\tc_service.exe"   tc_service_exe
REM   pause
REM   exit
  rem NX Patch: "NX 6.0.5.3 MP6, 10Feb11. See Maintenance letter for detailed list of fixes."
  call LibCheck.cmd "ugraf.exe" "6.0.5.3" "02-10-2011" "1,022,464" ugraf_exe_DPNE  ugraf_exe_Result ugraf_exe_Msg
  call LibCheck.cmd "libsyss.dll" "6.0.5.3" "02-10-2011" "4,103,168" libsyss_dll_DPNE  libsyss_dll_Result libsyss_dll_Msg
  rem  Tc 2007.1.8.6.B01_4 V2007.1.8.6_   b01_4   .   20110314.00
  call LibCheck.cmd "libnxmgr_im.dll" "2007.1.8.59240" "03-15-2011" "2,588,672" libnxmgr_im_dll_DPNE  libnxmgr_im_dll_Result libnxmgr_im_dll_Msg
  call LibCheck.cmd "tc_service.exe" "2007.1.8.59240"  "03-15-2011" "15,360" tc_service_exe_DPNE  tc_service_exe_Result tc_service_exe_Msg

 rem Step: Auswertung gesamt Ergebniss Patch Check:
 set ClientPatchCheck_Res=OK
 if /I "%ugraf_exe_Result%"       neq "OK" set ClientPatchCheck_Res=Err
 if /I "%libsyss_dll_Result%"     neq "OK" set ClientPatchCheck_Res=Err
 if /I "%libnxmgr_im_dll_Result%" neq "OK" set ClientPatchCheck_Res=Err
 if /I "%tc_service_exe_Result%"  neq "OK" set ClientPatchCheck_Res=Err

 if /I "%PrintResultDO:~-3,3%" equ "YES" (
   Echo Nx.Ugraf.exe......: %ugraf_exe_DPNE%:[%ugraf_exe_Result%]
   Echo                     %ugraf_exe_Msg%
   Echo Nx.libsyss.dll....: %libsyss_dll_DPNE%:[%libsyss_dll_Result%]
   Echo                     %libsyss_dll_Msg%
   Echo Tc.libnxmgr_im.dll: %libnxmgr_im_dll_DPNE%:[%libnxmgr_im_dll_Result%]
   Echo                     %libnxmgr_im_dll_Msg%
   Echo Tc.tc_service.exe.: %tc_service_exe_DPNE%:[%tc_service_exe_Result%]
   Echo                     %tc_service_exe_Msg%
   Echo Entire Result:....: %ClientPatchCheck_Res%
   if /i "%ClientPatchCheck_Res%" equ "ERR" (
     banner Res:%ClientPatchCheck_Res%
     Color C0
   ) else (
     Color A0
   )
 )
 endlocal& if "%1" neq "" set %1=%ClientPatchCheck_Res%
goto :eof

rem ============================================================================
:GetFull_DP
  set %1=%~dpnx2
 goto :eof

rem ============================================================================
:RefileClientPatchSaveInfo
 setlocal
  set FileGetVerinfo=%~1
  set FileGetVerinfoOrig=%~2
  set File_N=%~3
  call fileFindInPath_GetVerInfo.cmd "%FileGetVerinfo%" FileFound_DPNE FileInfo FileVer FileDate FileSize
  Echo rem %FileGetVerinfo%:[%FileInfo%]
  Echo call LibCheck.cmd "%FileGetVerinfoOrig%" "%FileVer%" "%FileDate%" "%FileSize%" %File_N%_DPNE  %File_N%_Result %File_N%_Msg>>"%InfoVer_DPNE%"
 endlocal

 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%"
 setlocal

   rem - TextToEcho erstellen
   set TextToEcho=%~1
   if "%TextToEcho%" equ ""  set TextToEcho=.
   if "%TextToEcho%" neq "." set TextToEcho= %TextToEcho%

   rem - Ausgabe in File
   set EchoToFile_DPNE=
   if "%2" neq "" (
    set EchoToFile_DPNE=%2
    set EchoToFile_DPNE=!EchoToFile_DPNE:"=!
    Echo!TextToEcho! >>"!EchoToFile_DPNE!"
   )

   set EchoToFile_DPNE=
   if "%3" neq "" (
    set EchoToFile_DPNE=%3
    set EchoToFile_DPNE=!EchoToFile_DPNE:"=!
    Echo!TextToEcho! >>"!EchoToFile_DPNE!"
   )

   rem - Ausgabe Console
   Echo%TextToEcho%

   rem - Ausgabe in :TracAc
REM    if "%TextToEcho%" neq "." call :TracAc "%TextToEcho%"

 :EchoEnd
 endlocal
 goto :eof
