WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WinInet
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

iFtpGet to get INI file

Keywords:   IniReadPvt iFtpGet

Question:

I 'manually' update an INI file on an FTP server. I then have a WinBatch script that does an iFtpGet of that INI file. I then try to read the file with the IniReadPvt. It seems to be reading some cached copy. How could this be?

Answer:

Precautions when using INI operations:

Do not mix file operations and INI operations. This is not a feature of WinBatch but of Windows. When you use the iniWritePvt() to update an INI file, Windows broadcasts a message to everybody so that processes that have to read the INI file know that the file needs to be re-read.

Overwriting an INI file with File operations (like iFtpGet) doesn't result in this broadcast. As a result, nobody, including WinBatch, will know that the file is changed, and everybody, including WinBatch, will use its buffered copy to continue processing.

So what can you do?

Maybe try using a different file name for the inifile each time it is downloaded. This way Windows cannot confuse it with a previously cached INI file. See the following code:
AddExtender("wwint34I.dll")
tophandle=iBegin(0,"","")
conhandle=iHostConnect(tophandle,"ftp.myserver.com",@FTP, "jane", "tarzan")
if conhandle==0
  message("ERROR","Unable to connect to host")
  exit
endif
newfilename=Timeymdhms()
;parsetime to get valid filename
newfilename=strreplace(newfilename,":","")
Currdir=iFtpDirGet(conhandle)
getfile=iFtpGet(conhandle,"%Currdir%\myfile.ini","c:\windows\desktop\%newfilename%.ini",0,0)
if getfile==0 then message("Oopps!",strcat("iFtpGet Failed check:",@CRLF," -Remote file path",@CRLF," -Overwrite Param(does local file already exist?)"))
iClose(conhandle)
iClose(tophandle)
;Maybe delete that inifile if its nolonger needed
;FileDelete("c:\windows\desktop\%newfilename%.ini")
Message("All","Done")
exit

Article ID:   W12597
Filename:   iFtpGet to get INI file.txt
File Created: 2017:07:28:12:58:47
Last Updated: 2001:03:01:14:23:42