@echo off 

set  FTP_SERVER=%1
set  FTP_USER=%2
set  FTP_PASS=%3
set  LOCAL_DIR=%4
set  REMOTE_FILE=%5
set  FINAL_PAUSE=%6

echo FTP_SERVER=%FTP_SERVER%
echo FTP_USER=%FTP_USER%
echo FTP_PASS=%FTP_PASS%
echo LOCAL_DIR=%LOCAL_DIR%
echo FINAL_PAUSE=%FINAL_PAUSE%

if  %FINAL_PAUSE%==*YES (
     echo on
)

cd %LOCAL_DIR%

set FTP_CMD=%LOCAL_DIR%\ftpcmd_txt.%RANDOM%
echo open %FTP_SERVER% > %FTP_CMD%
echo %FTP_USER% >> %FTP_CMD%
echo %FTP_PASS% >> %FTP_CMD%
echo quote type c 943 >> %FTP_CMD%
echo quote site namefmt 1 >> %FTP_CMD%
echo bin >> %FTP_CMD%
echo get %REMOTE_FILE% >> %FTP_CMD%
echo del %REMOTE_FILE% >> %FTP_CMD%
echo bye >> %FTP_CMD%

ftp -s:%FTP_CMD%

for %%f in (%REMOTE_FILE%) do (
    set LOCAL_EXCEL=%%~nxf
)

echo %LOCAL_EXCEL%
start /min %LOCAL_EXCEL%

if %FINAL_PAUSE%==*YES (
   pause
)
del %FTP_CMD%
exit 0

