::----------------------------------------------------------------
:: Runs gmStudio tasks, tools, and reports in batch 
:: and consolidate report files and logs in this folder.
::-----------------------------------------------------------------

::-----------------------------------------------------------------
:: Initialize environment
:: Edit the following two variables to indicate where
:: the gmStudio EXE and application config files are located
::-----------------------------------------------------------------
@echo off

set wrk=%TestBed%

set GmStudioExe=%ProgramFiles%\GreatMigrations\gmStudio\gmStudio.exe
if not exist "%GmStudioExe%" set GmStudioExe=%ProgramFiles(x86)%\GreatMigrations\gmStudio\gmStudio.exe
if not exist "%GmStudioExe%" echo cannot find gmStudio.exe && goto end

set gmStudioCfg=%ProgramFiles%\GreatMigrations\gmStudio\gmStudio.cfg
if not exist "%gmStudioCfg%" set gmStudioCfg=%ProgramFiles(x86)%\GreatMigrations\gmStudio\gmStudio.cfg
if not exist "%GmStudioCfg%" echo cannot find gmStudio.cfg && goto end

copy "%GmStudioCfg%" .>nul

::-----------------------------------------------------------------
:: delete aggregated reports from prior runs 
:: (or leave them for appending)
::-----------------------------------------------------------------

if exist GMSTUDIO_ERROR*.LOG del GMSTUDIO_ERROR*.LOG

:: set delRpt=NO if resuming a run and new reports will be appended 
:: to old ones, otherwise set=NO to wipe the slate clean

set delRpt=YES

if [%delRpt%]==[YES] (

   if exist  *.wc    del *.wc

   if exist  RegTest.tab    del RegTest.tab   
   if exist  Session.tab    del Session.tab   

   if exist  AllLog.txt     del AllLog.txt    
   if exist  BldLog.tab     del BldLog.tab    
   if exist  BndScan.tab    del BndScan.tab    
   if exist  Bundle.tab     del Bundle.tab    
   if exist  LibHeaders.tab del LibHeaders.tab
   if exist  LibProgIds.tab del LibProgIds.tab
   if exist  MigSet.tab     del MigSet.tab    
   if exist  MigStat.txt    del MigStat.txt   
   if exist  SrcRef.tab     del SrcRef.tab    
   if exist  SrcScan.tab    del SrcScan.tab   
   if exist  SrcStruct.tab  del SrcStruct.tab 
   if exist  TranLog.tab    del TranLog.tab   
   if exist  gmProjects.tab del gmProjects.tab
   if exist  SrcOrder.txt   del SrcOrder.txt
   if exist  Metrics.htm    del Metrics.htm

)

::-----------------------------------------------------------------
:: Run the samples
::-----------------------------------------------------------------

:: CALL runbatch 

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '.\TimeBatch.ps1' runbatch.cmd" 
call psdir "." 

:end
:: pause if desired
if [%1%]==[] pause