:: :: 2024 Jan16 install CDF patch into IDL and ENVI echo off setlocal EnableDelayedExpansion echo. echo This is the script to install the latest IDL patch from SPDF onto your Windows echo You may need to enter the administrator account's password. set CDIR=%cd% set VERSION=3.9.1 set ftp=https://spdf.gsfc.nasa.gov/pub/software/cdf/dist/cdf39_1/idl set IDL_Win64=%ftp%/windows/x64/idl_cdf.dll set IDL_Win32=%ftp%/windows/x86/idl_cdf.dll set IDL_DLM=%ftp%/idl_cdf.dlm set LEAPS=https://cdf.gsfc.nasa.gov/html/CDFLeapSeconds.txt set SHOWVERS=%ftp%/showcdfversion.pro set SHOWVERS2=%ftp%/showcdfversion2.pro set GET=%CDIR%\wget -nv --no-check-certificate :: find all installed versions of IDL and ENVI echo. echo This is the list of currently available IDL version(s) installed on your echo Windows in c:\program files\ directory (might take a moment...): echo. set ToFind="idl_cdf.dll$" if exist "c:\program files\nv5\" ( set DIR1="c:\program files\nv5" ) else ( set DIR1= ) if exist "c:\program files\harris\" ( set DIR2="c:\program files\harris" ) else ( set DIR2= ) if exist "c:\program files\exelis\" ( set DIR3="c:\program files\exelis" ) else ( set DIR3= ) if exist "c:\program files\itt\" ( set DIR4="c:\program files\itt" ) else ( set DIR4= ) dir /s/b %DIR1% %DIR2% %DIR3% %DIR4% 2> nul | findstr %ToFind% > myidl.txt set /a fn=0 FOR /f "delims=" %%a in ('type myidl.txt') do ( set /a fn+=1 set "line[!fn!]=%%a" ) rem Display array elements For /L %%i in (1,1,%fn%) do ( rem echo "%%i" ) "!line[%%i]!" echo %%i^) !line[%%i]:~0,-12! ) :toselect echo. set /p idlid="Select a number from the above list to be replaced by the latest patch, or 0 to end: " if %idlid% geq 1 if %idlid% leq %fn% goto :goodone if %idlid% equ 0 goto :toend echo %idlid%: bad input goto :toselect :goodone echo. echo You picked number: %idlid% for !line[%idlid%]! for /F "tokens=4 delims=\" %%a in ("!line[%idlid%]!") do ( echo %%a set selected=%%a ) set IDL_DLM=%IDL_DLM% if not x"!line[%idlid%]:x86_64=!" == x"!line[%idlid%]!" ( set IDL_DLL=%IDL_Win64% ) else ( if not !"%line[%idlid%]:x86=!" == x"!line[%idlid%]!" ( set IDL_DLL=%IDL_Win32% ) else ( echo Error: require IDL/ENVI bin path for Windows 32/64 goto :toend ) ) for /F "tokens=2,3,4 delims=/ " %%a in ('date /t') do ( set todayT=%%c%%a%%b ) for /F "tokens=1,2,3 delims=: " %%a in ('time /t') do ( set timeT=%%a%%b%%c ) set TEMPDIRx=idl_save_%selected%_%todayT%%timeT% echo Backing up the old files and downloading the new ones to %TEMPDIRx% mkdir %TEMPDIRx% cd %TEMPDIRx% echo %GET% %IDL_DLL% %GET% %IDL_DLL% if %errorlevel% neq 0 ( echo Error: failed %GET% %IDL_DLL% goto :toend ) echo. echo %GET% %IDL_DLM% %GET% %IDL_DLM% if %errorlevel% neq 0 ( echo Error: failed %GET% %IDL_DLM% goto :toend ) echo. echo %GET% %LEAPS%" %GET% %LEAPS% if %errorlevel% neq 0 ( echo Error: failed %GET% %LEAPS% goto :toend ) echo. echo %GET% %SHOWVERS% %GET% %SHOWVERS% if %errorlevel% neq 0 ( echo Error: failed %GET% %SHOWVERS% goto :toend ) echo. echo %GET% %SHOWVERS2% %GET% %SHOWVERS2% if %errorlevel% neq 0 ( echo Error: failed %GET% %SHOWVERS% goto :toend ) set opt=!line[%idlid%]:~0,-12! echo dir=%opt% cd "%opt%" echo Enter current dir=!cd! set mydate=%date:~10,4%-%date:~7,2%-%date:~4,2% if not exist idl_cdf.dll-orig-%mydate% ( echo rename idl_cdf.dll idl_cdf.dll-orig-%mydate% rename idl_cdf.dll idl_cdf.dll-orig-%mydate% echo rename idl_cdf.dlm idl_cdf.dlm-orig-%mydate% rename idl_cdf.dlm idl_cdf.dlm-orig-%mydate% ) echo copy /y "%CDIR%\%TEMPDIRx%\idl_cdf.dll" . copy /y "%CDIR%\%TEMPDIRx%\idl_cdf.dll" . copy /y "%CDIR%\%TEMPDIRx%\idl_cdf.dlm" . cd "%CDIR%" :: echo to temp: %CDIR%\%TEMPDIRx% echo. echo Testing the installation... for version: %VERSION% echo. if exist "!line[%idlid%]!\..\..\..\resource\xprinter" ( set XPPATH="!line[%idlid%]!\..\..\..\resource\xprinter" ) set IDL_STARTUP="%CDIR%\%TEMPDIRx%\showcdfversion2.pro" set IDL_DIR="!line[%idlid%]!\..\..\.." "!line[%idlid%]!\..\idl" >%CDIR%\%TEMPDIRx%\myout.txt type %CDIR%\%TEMPDIRx%\myout.txt echo. echo. echo The patch (for .dll and .dlm) is installed in %opt% echo. echo NOTE: The original version (.dlm and .dll) are saved and renamed echo with "-orig-%mydate%" appended to the files. echo. del %TEMPDIRx%\showcdfversion.pro rem %TEMPDIRx%\showcdfversion2.pro rem %CDIR%\%TEMPDIRx%\myout.txt del %CDIR%\myidl.txt :toend endlocal