sanam_bl
sanam_bl

Reputation: 329

Not able to Delete file using NSIS

I have a question related to NSIS. I have an installer created by NSIS in ("c:/Installer/Installer.exe" folder). When I run the installer it creates a log file("c:/Installer/installlog.txt") in the installation folder. After I successfully run Installer.exe I want only the installlog.txt to be deleted from "c:/Installer" .

I have the following function

Function .onInstSuccess
    call cleanUp
    ifSilent 0 +2
             ${LogText} "INFO :: Application has been installed"
             CopyFiles "$EXEDIR\${INSTALL_LOG}" "$Dir\LogFiles\"
             IfFileExists "$Dir\LogFiles\{INSTALL_LOG}" DoNothing CopyAgain
             CopyAgain:
                CopyFiles "$DIR\${INSTALL_LOG}" "$Dir\LogFiles\"
                Delete "$DIR\${INSTALL_LOG}"
                goto DoNothing
             DoNothing:           
             SetOutPath $EXEDIR     
             Delete "$EXEDIR\*.log" ;....................**but the file does not get deleted**
FunctionEnd

can some one please tell me how can I make this work. I need to fix this as soon as possible, help on this is greatly appreciated

Upvotes: 0

Views: 6591

Answers (1)

Anders
Anders

Reputation: 101656

I assume you are using these logging macros. You should call ${LogSetOff} after the last call to ${LogText} so the file handle is closed, you should then be able to delete the file.

Also, using Delete "$EXEDIR\*.log" is not a good idea, you already know the filename...

Upvotes: 1

Related Questions