Archive: WriteINIStr creates new files, but won't update existing


WriteINIStr creates new files, but won't update existing
I'm creating a desktop shortcut to distribute to our applications users but I've noticed it only creates a new file if you change the filename you are passing to a filename not yet used. When its a new .URL filename, it creates a new .URL file with the current data. If I keep using the old .URL filename, it doesn't update the file that already exists. Even if I delete the old .URL file manually and even clear my recycle bin and then I run the script again, if I'm re-using a file name, it manages to create the old file with old url again. I've tried this in XP and Windows 7. Do I need to do something with temp files? I haven't seen that in anyone elses code. Thanks! I've been trying to figure out this final detail for hours. Here's the excerpt of the code:

Section "" ;No components page, name is not important
!macro CreateInternetShortcut FILENAME URL ICONFILE ICONINDEX
nsislog::log "c:\logfile.txt" "Creating Internet shortcut."
WriteINIStr "${FILENAME}.url" "InternetShortcut" "URL" "${URL}"
WriteINIStr "${FILENAME}.url" "InternetShortcut" "IconFile" "${ICONFILE}"
WriteINIStr "${FILENAME}.url" "InternetShortcut" "IconIndex" "${ICONINDEX}"
!macroend

!insertmacro CreateInternetShortcut \
"$DESKTOP\Econ 3" \
"http://mysite" \
"$SYSDIR\favicon.ico" "0"

SectionEnd ; end the section


Is it possible that you are encountering a problem with quotation marks? What happens if you change the filename parameter from "$DESKTOP\Econ 3" to "$DESKTOP\Econ3" ?

What about changing the quotation marks in the macro from " (quotation marks) to ` (Grave Accent) ?


Are you on Windows 98? Try FlushINI.

Stu


Thanks for the input! I'm actually using Windows XP and 7, not 98, but I ran with your ideas and tried putting flushini before, then after, and a delete. I also changed it to no spaces in the file name and tried single quotes and ` in the macro. No luck :(


nevermind, I figured it out! If i delete the exe before I recompile, it will update the .url file I'm creating/modifying :)


oops, false alarm! I haven't been able to get it to update since.


i figured something else out, although its not a solution. In both XP and Windows 7, if I delete the .URL file AND reboot, when I run the .exe if creates a new .URL file. So i figured out a way to make it work, but thats not user friendly. If I only delete the .URL file, or only reboot, then run the .exe, the .URL file is still what it was before the delete or reboot.


Try creating the URL file in your install directory and creating a shortcut to that instead. Perhaps because it is on the desktop it is cached in some way.

Stu


Thanks, I tried a different directory to install the URL shortcut to. That didn't resolve it either. I think this is solved though. I noticed that the file is actually being updated with the right http path each time, because theres a file preview in Windows 7. I had been testing by right clicking and looking at properties, which isn't updating for some reason, but I guess thats just life.


never mind