mickmo
31st May 2002 21:18 UTC
Remove OutFile
Hello, I was told by my boss to learn NSIS and use it for the program I created. I finally figured out how to use it thanks to the documentation and this discussion site. However, there is one thing I would like to do in NSIS and haven't been able to fiqure out. Is it possible to delete the Outfile after the user installs the program?
I have tried to use delete command and I even hard coded the path and nothing seemed to work. Is it possible to delete this file through code? If it is how?
Thank you.
Smile2Me
1st June 2002 08:41 UTC
Read this.
If you also want a proper uninstall, do something like this
name deleter
outfile deleter.exe
SilentInstall silent
section
Sleep 500
Call GetParameters
Pop $0
Delete $0
sectionend
Function GetParameters
Push $0
Push $1
Push $2
StrCpy $0 $CMDLINE 1
StrCpy $1 '"'
StrCpy $2 1
StrCmp $0 '"' loop
StrCpy $1 ' ' ; we're scanning for a space instead of a quote
loop:
StrCpy $0 $CMDLINE 1 $2
StrCmp $0 $1 loop2
StrCmp $0 "" loop2
IntOp $2 $2 + 1
Goto loop
loop2:
IntOp $2 $2 + 1
StrCpy $0 $CMDLINE 1 $2
StrCmp $0 " " loop2
StrCpy $0 $CMDLINE "" $2
Pop $2
Pop $1
Exch $0
FunctionEnd
That's the deleter. In the installer do something like this
outfile prob.exe
name prob
section
sectionend
function .onInstSuccess
SetOutPath $TEMP
File /oname=_deleter.exe deleter.exe
Exec '$TEMP\_deleter.exe $EXEDIR\prob.exe'
functionend
The exe might have been renamed though...
-Hendri.
mickmo
3rd June 2002 15:55 UTC
Thank you
Thank you for your help. It is much appreciated.
Smile2Me
3rd June 2002 17:16 UTC
Good :)
Thx,
-Hendri.