:: Hi-Track Monitor Pre-Install Check for Windows :: If the TEMP / TMP variables contain special characters the the Java based installer :: may fail. This script detects the presence of special characters and prompts the user :: to define a different TEMP/TMP directory. :: In some cases, the TEMP/TMP variables don't include special characters so the username :: is also checked :: The original values for TEMP/TMP will be restored :: The Hi-Track Monitor Installer (HTinst.exe) is expected to be in the same directory. :: Copyright Hitachi Data Systems 2008 @echo off Title Hi-Track Monitor Pre-Install Check echo Hi-Track Monitor Pre-Install Check echo Checking Environment ... please wait. set CHANGE=false set oldTmp=%TMP% set oldTemp=%TEMP% Call :CheckSpecial %TMP% if %SPECIAL% == true set CHANGE=true Call :CheckSpecial %TEMP% if %SPECIAL% == true set CHANGE=true Call :CheckSpecial %USERNAME% if %SPECIAL% == true set CHANGE=true if %CHANGE% == false goto runInstall :PromptUser echo The current TEMP directory path, or Username contains special characters echo Input the full path of a temporary directory without special characters echo The directory must exist. set /p newTemp= set blank=blank%newTemp% if %blank% NEQ blank goto newCheck2 echo Temp Directory must not be blank ! goto PromptUser :newCheck2 Call :CheckSpecial %newTemp% if %SPECIAL% == false goto newCheck3 echo New Temp Direcory must not contain special characters ! goto PromptUser :newCheck3 if exist %newTemp% goto newCheck4 echo Directory '%newTemp%' does not exist goto PromptUser :newCheck4 set TMP=%newTemp% set TEMP=%newTemp% :runInstall echo Starting Hi-Track Monitor Installer start /w HTinst.exe if %CHANGE == "false" goto endInstall set TMP=%oldTmp% set TEMP=%oldTemp% :endInstall echo "Hi-Track Monitor Install Complete" goto :eof :: Does the caller's parameter contain a 'special' character ? :: Return SPECIAL=true if so :CheckSpecial set SPECIAL=false call :CheckOneChar %1 "-" call :CheckOneChar %1 "+" call :CheckOneChar %1 "*" call :CheckOneChar %1 "/" call :CheckOneChar %1 "%" call :CheckOneChar %1 "(" call :CheckOneChar %1 ")" call :CheckOneChar %1 "," call :CheckOneChar %1 "!" call :CheckOneChar %1 "<" call :CheckOneChar %1 ">" call :CheckOneChar %1 "=" call :CheckOneChar %1 "^" call :CheckOneChar %1 "'" goto :eof :: If 2nd parameter exists in 1st parameter then set SPECIAL-true :CheckOneChar echo %1 | find %2 > nul if not errorlevel 1 set SPECIAL=true goto :eof