Archive: NSIS and Touch


NSIS and Touch
I'm a novice at this and am trying touch a single file when executing the installer I'm creating using NSIS. I want this single file to show the install date as the "last modified" so that I know when it was installed (I don't want to use SetDateSave because that changes the date on all the files). Has anyone had success doing this sort of thing?


You can open it and close it right away with FileOpen and FileClose.


You can open it and close it right away with FileOpen and FileClose.
Make sure to make the open mode "a" (as opposed to "r" or "w") because "r" will only open the file for reading, and "w" will wipe the file clean.

FileOpen $0 "$INSTDIR\replace_with_file.name" a
FileClose $0


-dandaman32

I try putting that in a fuction and get a 'install function "TouchFile" not referenced - zeroing code (0-4) out
' error.

Function TouchFile
FileOpen $0 $INSTDIR\test.txt a
FileClose $0
FunctionEnd


Here's what you're looking for:


Function TouchFile
Exch $0
Push $1
FileOpen $1 $0 a
FileClose $1
Pop $1
Exch $0
FunctionEnd

...and later, in your sections...

Push "$INSTDIR\text.txt"
Call TouchFile


-dandaman32

Someone has already written a pretty nice function for "touch". This might be interesting to you.


Had tried that Touch function before w/o success, but went back an made it work pretty well with using under a "Function .onGUIEnd" section. Thanks for all the input.