- NSIS Discussion
- Extremely dumb newbie question regarding Delete
Archive: Extremely dumb newbie question regarding Delete
Mistral
2nd April 2002 08:44 UTC
Extremely dumb newbie question regarding Delete
I'm trying to make a silent patch installer that users of my mIRC script can download automatically and it patch the script and then disappear.
The problem I'm having is that it extracts all the files OK, but it does not delete the installer file. Can someone please point me in the direction of my error please?
Name "test"
OutFile "testpatch.exe"
SetCompress auto
CRCCheck on
AutoCloseWindow true
ShowInstDetails hide
SilentInstall Silent
InstallDir "$EXEDIR"
DirShow hide
Section "default"
SetOutPath "$INSTDIR"
file /r "C:\Documents and Settings\Mistral\Desktop\test\system"
SectionEnd
Function .onInstSuccess
Delete /REBOOTOK "$EXEDIR\testpatch.exe" ; (tried $INSTDIR too ... no luck)
FunctionEnd
Many thanks in advance
Mistral
Pomflain
2nd April 2002 09:01 UTC
Have you tried $OUTDIR?
Mistral
2nd April 2002 09:04 UTC
No I hadn't, just did. Same result :(
SQwerl
2nd April 2002 09:43 UTC
Function .onInstSuccess
Delete /REBOOTOK "$EXEDIR\testpatch.exe" ; (tried $INSTDIR too ... no luck)
FunctionEnd
Have you tried a 'Section' instead?
Section Delete_EXE
Delete "$INSTDIR\testpatch.exe"
SectionEnd
Just a guess, not sure if it would work or not.
Smile2Me
2nd April 2002 15:18 UTC
I guess the installer is unable to delete itself (???)
I tried this script on my desktop:
outfile prob.exe
name prob
section
delete $DESKTOP\prob.exe
sectionend
and indeed, it didn't delete itself.
Maybe at reboot, but I don't think so...
Good luck, Hendri.
Ps: why deleting the installer???
Smile2Me
2nd April 2002 15:28 UTC
outfile prob.exe
name prob
section
delete /rebootok $DESKTOP\prob.exe
sectionend
This works. Your sure the reference in your original function is correct? If correct, this would mean, that there is a bug in NSIS, because from a section it works and not from a function. I expect that you need to debug the code to check the path to the file you want to delete. So just put a messagebox before the delete command and run the code. Post your results here, then we know if this was a bug or a mistake...
Good luck, greetz,
Hendri.
Mistral
2nd April 2002 15:57 UTC
Function .onInstSuccess
GetFullPathName $R1 "$EXEDIR\testpatch.exe"
MessageBox MB_YESNO "EXE found at $R1, confirm Delete?" IDNO NoDelete
Delete /REBOOTOK "$EXEDIR\testpatch.exe"
NoDelete:
FunctionEnd
Returns "EXE Found at c:\Documents and Settings\Mistral\Desktop\test2\testpatch.exe, confirm Delete?"
Although this is a correct path, upon confirmation it still does not delete.
I hadn't tried in a section before, although when I tried it it did not work for me, no matter what I tried. Even copying your text did not work. Maybe this is a problem with only Windows XP? Could someone else try it on a different OS and see if they get the same results?
PS. I suppose I could just write in a .remove event in my script, but I know that this is possible, as I have seen it being done with another patch for another mIRC script, which I'd like to emulate.
Mistral
2nd April 2002 16:35 UTC
Workaround found
Name "test"
OutFile "testpatch.exe"
SetCompress auto
CRCCheck on
AutoCloseWindow true
ShowInstDetails hide
SilentInstall Silent
InstallDir "$EXEDIR"
DirShow hide
Section "default" ; (default section)
SetOutPath "$INSTDIR"
file /r "C:\Documents and Settings\Mistral\Desktop\test\system"
WriteUninstaller $INSTDIR\Uninst.exe
SectionEnd ; end of default section
Section "Uninstall"
SetAutoClose true
Delete $INSTDIR\Uninst.exe
Delete $INSTDIR\testpatch.exe
SectionEnd
Function .onInstSuccess
ExecWait $INSTDIR\Uninst.exe
FunctionEnd
This works as I wanted ... I suppose I should have been more logical in my thinking. Thanks for your help.
Smile2Me
2nd April 2002 17:05 UTC
This is a nice solution to the problem of removing the exe itself! Well done! :)
BTW, Delete /rebootok also works fine, but then you will need to allow for rebooting the machine. That is indeed less preferrable. If one needs the uninstall section for a real uninstall, one could use a small batch file or vb script to delete thge original install exe if ou don't want to reboot...
Greetz, Hendri.