@Echo off
 setlocal EnableDelayedExpansion EnableExtensions
 rem -----------------------------------------------------------------------------------------
 rem Setzt die User Defaults fuer Programme:
 rem - PsPad
 rem - MwSnap
 rem Stand 08.02.2010 J.fes

 rem Optionsparameter:
 rem P1 Quiet Modus
 set Quiet=false
 if /I "%1"=="/Quiet" set Quiet=true

 rem Root Variablen
 set MyApplBase_TP=JobManagerV3
 set MyApplProd_N=PLMJobManagerV3

REM  set MyAppl_Root_DP=
REM  set MyAppl_Root_DP=%MyAppl_Root_DP:~0,-1%

 rem
 call :PathCutLastDir MyAppl_Root_DP %~dp0
 call :PathCutLastDir MyAppl_Root_DP %MyAppl_Root_DP%
 
 rem Server Dirs ermitteln
 set BinServer_DP=%MyAppl_Root_DP%\01-BinServer
 set BinClient_DP=%MyAppl_Root_DP%\02-BinClient
 set BinPublic_DP=%MyAppl_Root_DP%\03-BinPublic
 set Install_DP=%MyAppl_Root_DP%\99-Install
 
 if /i "%Quiet%" neq "true" (
  set MyTitle=Setup User Standard
  Echo %MyTitle%
  Title %MyTitle%
 )

REM   10.02.2010 18:20 entnommen da PsPad auf Zentral Use umgestellt
REM  set Path=%BinPublic_DP%;%Path%
REM  if /i "%Quiet%" neq "true"  (
REM  Echo.
REM  Echo --------------------------------------------------------------------------
REM  Echo -Step: "PSPad defaults setzen"
REM  )
REM  set PsPadUserDefault_Source_DP=%BinPublic_DP%\PSPad editor\_setup_user_Application Data\PSpad
REM  set PsPadUserDefault_Dest_DP=%APPDATA%\PSpad
REM
REM  set PsPadUserDefaultsDoImport=false
REM  set PsPadUserDefaultsDoExport=true
REM  if /i "%ComputerName%" equ "JF-18" (
REM    if not exist "%PsPadUserDefault_Dest_DP%" (
REM      set PsPadUserDefaultsDoImport=true
REM    ) else (
REM      set PsPadUserDefaultsDoExport=true
REM    )
REM  ) else (
REM    set PsPadUserDefaultsDoImport=true
REM  )
REM
REM
REM  if /i "%PsPadUserDefaultsDoImport%"=="true" (
REM   if /i "%Quiet%" neq "true" (
REM   Echo Import PsPad User Default's
REM   Echo von ...: %PsPadUserDefault_Source_DP%
REM   Echo nach ..: %PsPadUserDefault_Dest_DP%
REM   )
REM   set toRun=robocopy "%PsPadUserDefault_Source_DP%" "%PsPadUserDefault_Dest_DP%" /xf Recent.INI /mir /e /r:0 /w:0 /np /njh /njs /nfl /ndl
REM   !toRun! >nul 1>nul 2>nul
REM  )
REM
REM  if /i "%PsPadUserDefaultsDoExport%"=="true" (
REM   if /i "%Quiet%" neq "true" (
REM   Echo Export PsPad User Default's nur auf:[\\JF-18]
REM   Echo von ...: %PsPadUserDefault_Dest_DP%
REM   Echo nach ..: %PsPadUserDefault_Source_DP%
REM   )
REM   set toRun=robocopy "%PsPadUserDefault_Dest_DP%" "%PsPadUserDefault_Source_DP%" /xf Recent.INI /mir /e /r:0 /w:0 /np /njh /njs /nfl /ndl
REM   !toRun! >nul 1>nul 2>nul
REM  )

 if /i "%Quiet%" neq "true" (
 Echo --------------------------------------------------------------------------
 Echo -Step: "MWSnap User defaults setzen"
 )
 set MWSnapReg_DPNE=%BinPublic_DP%\MWSnap\MwSnapDefault-Settings.reg

 if /i "%ComputerName%" equ "JF-18" (
  rem set MWSnapUserDefaultsDoRegImport=false
  if /i "%Quiet%" neq "true" (
  Echo Export RegKey:[HKEY_CURRENT_USER\Software\MirWoj] nur auf:[\\JF-18]
  Echo File...: %MWSnapReg_DPNE%
  )
  set toRun=reg.exe Export HKEY_CURRENT_USER\Software\MirWoj "%MWSnapReg_DPNE%"
  !toRun! >nul 1>nul 2>nul
 ) else (
  rem   Echo Importieren der Reg Key: [HKEY_CURRENT_USER\Software\MirWoj]
  if /i "%Quiet%" neq "true" (
  Echo File...: %MWSnapReg_DPNE%
  )
  set toRun=reg.exe IMPORT "%MWSnapReg_DPNE%"
  !toRun! >nul 1>nul 2>nul
 )

 rem ===========================================================================
 rem In diesem Ordner werden die mtx Datein gespeichert:
 rem refile roles C:\Dokumente und Einstellungen\infodba\Lokale Einstellungen\Anwendungsdaten\Unigraphics Solutions\NX6\roles

 set RefileRoule_DoCopy=false
 if exist "%USERPROFILE%\Lokale Einstellungen\Anwendungsdaten" (
   set RefileRoule_DoCopy=true
   set RefileRoule_Dest_DP=!USERPROFILE!\Lokale Einstellungen\Anwendungsdaten\Unigraphics Solutions\NX6\roles
 )

 set RefileRoule_NE=Refile_NX6_Roule.mtx
 set RefileRoule_Dest_DPNE=%RefileRoule_Dest_DP%\%RefileRoule_NE%
 set RefileRoule_Source_DP=%Install_DP%\NxTcSettings
 set RefileRoule_Source_DPNE=!RefileRoule_Source_DP!\%RefileRoule_NE%
 rem dir "%RefileRoule_Source_DPNE%"

 
 if /i "%Quiet%" neq "true" (
 Echo --------------------------------------------------------------------------
 Echo -Step: "Copy User defaults: RefileRoule %RefileRoule_NE%"
 )

 if /i "%RefileRoule_DoCopy%" equ "true" (
  if /i "%ComputerName%" equ "WPC80846" (
   Echo Copy NX User Roule nur auf [\\WPC80846]:
   Echo File...: !RefileRoule_NE!
   Echo from...: !RefileRoule_Dest_DP!
   Echo to.....: !RefileRoule_Source_DP!
   set toRun=copy "!RefileRoule_Dest_DPNE!" "!RefileRoule_Source_DPNE!"
   !toRun!
   pause
 ) else (
  if /i "%Quiet%" neq "true" (
    Echo Copy NX User Roule :
    Echo File...: !RefileRoule_NE!
    Echo from...: !RefileRoule_Source_DP!
    Echo to.....: !RefileRoule_Dest_DP!
    )
   if not exist "!RefileRoule_Dest_DP!" md "!RefileRoule_Dest_DP!"
   set toRun=copy "!RefileRoule_Source_DPNE!" "!RefileRoule_Dest_DPNE!"
   !toRun! >nul 1>nul 2>nul
 )
 ) else (
   if /i "%Quiet%" neq "true" (
   Echo Info...: did not copy "!RefileRoule_NE!" to Local Settings
   Echo          Software currently checks only
   Echo          this Path: !USERPROFILE!\Lokale Einstellungen\Anwendungsdaten
   )
 )

 goto :ende


:ErrExit
 call :Echo ---------------------------------------
 call :Echo Error up in:
 call :Echo %0
 call :Echo please check your Logfile
 call :Echo %Log_DPNE%
 Pause
 goto :eof


rem ##### ------------ Standard Subroutines --------------------- ######
:PathCutLastDir
 rem schneidet das letzte Verzeichniss Uebergeben path ab
 rem P1 = Name der Variablen
 rem P2 = der Übergebene Path
 rem Example : call :PathCutLastDir EntwRoot_LP %~dp0
 rem Example : call :PathCutLastDir MyVar %~dp0

 set PathCutLastDir$temp=%2
 set PathCutLastDir$tempLastChar=%PathCutLastDir$temp:~-1%
 set PathCutLastDir$tempNoBacks=%PathCutLastDir$temp:~0,-1%

 if "%PathCutLastDir$tempLastChar%"=="\" (
   rem "\" abschneiden wenn vorhanden
   call :PathCutLastDirDo PathCutLastDir$tempRes %PathCutLastDir$tempNoBacks%
 ) else (
   rem
   call :PathCutLastDirDo PathCutLastDir$tempRes %PathCutLastDir$temp%
 )
 set PathCutLastDir$tempRes=%PathCutLastDir$tempRes:~0,-1%
 set %1=%PathCutLastDir$tempRes%
 set PathCutLastDir$temp=
 set PathCutLastDirDo$temp1=
 set PathCutLastDir$tempNoBacks=
 set PathCutLastDir$tempNoLastChar=
 set PathCutLastDir$tempLastChar=
 set PathCutLastDir$tempRes=
 goto :eof

:PathCutLastDirDo
 rem hiermit schneiden wir den Path ab
 rem echo.
 rem Echo P1=%1 P2=%2
 set PathCutLastDirDo$temp=%~dp2
 rem "\" abschneiden
 set PathCutLastDirDo$temp1=%PathCutLastDir$temp:~0,-1%
 set %1=%PathCutLastDirDo$temp%
 set PathCutLastDirDo$temp=
 set PathCutLastDirDo$temp1=
 goto :eof


:DateTimeNowGet
 rem call :DateTimeNowGet
 rem Set File_LPNE=%DatRoot_LP%\MyName-%DateTimeNowFileExt%.txt


 if     "%time:~0,1%"==" " set time-h=0%time:~1,1%
 if not "%time:~0,1%"==" " set time-h=%time:~0,2%

 if     "%time:~3,1%"==" " set time-m=0%time:~4,1%
 if not "%time:~3,1%"==" " set time-m=%time:~3,2%

 set Date-Y=%Date:~6,4%
 set Date-M=%Date:~3,2%
 set Date-D=%Date:~0,2%
 set DateTimeNowFileExt=%Date-Y%-%Date-M%-%Date-D%-%time-h%-%time-m%
 goto :eof


:Ende
 if /i "%Quiet%" neq "true" Pause
 endlocal
