@echo off

title Connectivity Check

setlocal

@REM Set default values

if [%1]==[/?] goto Usage
if [%1]==[] goto Usage
if [%2]==[] goto Usage

@REM Handle command line args
set "EndpointsFileName=%~1"
set "NameResolutionFileName=%~2"
set "OutDir=%~3"
set "CheckHostsFile=%~4"
set "PauseAfter=%~5"

@REM Map temporary drive to be able to handle UNC path
pushd %0\..
set "ROOT=%cd%"

@REM Run script
powershell -ExecutionPolicy Bypass "%ROOT%\ConnectivityCheck.ps1" "%EndpointsFileName%" "%NameResolutionFileName%" "%OutDir%" "%CheckHostsFile%"

@REM Unmap temporary drive used to handle UNC path
popd

goto Exit

:Usage
echo %~n0 endpoints_file name_resolution_file [out_dir] [check_hosts_file] [pause_after]
echo Examples:
echo %~n0 endpoints.txt name_resolution.txt C:\temp true


:Exit
@REM Pause if desired flag is set
if /i "%PauseAfter%" == "true" pause

endlocal
