@echo off

set newSyntax=ok
for /D %%i in ("%newSyntax%") do set newSyntax=%%~si

:: set TEMP variable if not already set
if "%xset_tmp%" == "" set xset_tmp=%temp%
if "%xset_tmp%" == "" set xset_tmp=%SYSTEMDRIVE%\.
if [%newSyntax%] == [ok] for /D %%i in ("%xset_tmp%") do set xset_tmp=%%~si

:: For Windows 2000 (or later) only
set xset_rnd=%RANDOM%

set xsetpath=
if exist "%~dp0.\xset.exe" set xsetpath=%~dp0
if [%newSyntax%] == [ok] for %%i in ("%xsetpath%") do set xsetpath=%%~si
set XSET_MSG=

if not %1. == . goto Args
"%xsetpath%xset.exe"
goto END

:Args
:: Use /NT, /OS2 or /REXX to specify the environment you use (/NT & /OS2 are equivalent)
"%xsetpath%xset.exe" /NT %*

if not exist "%xset_tmp%\xst%xset_rnd%.cmd" goto END
call "%xset_tmp%\xst%xset_rnd%.cmd"
del/f "%xset_tmp%\xst%xset_rnd%.cmd"

:END
if exist "%xset_tmp%\xst%xset_rnd%.sem" del/f "%xset_tmp%\xst%xset_rnd%.sem"
if exist "%xset_tmp%\_xset_in.txt" del/f "%xset_tmp%\_xset_in.txt"
set xsetpath=
set xset_rnd=

