- NSIS Discussion
- SelfDel plugin crashes on Win7 64Bit
Archive: SelfDel plugin crashes on Win7 64Bit
adriatik
17th August 2010 10:15 UTC
SelfDel plugin crashes on Win7 64Bit
Hi!
I am facing a problem with the SelfDel plugin for NSIS on machines with win 7 64 bit. i am not sure which is the problem win 7 or 64bit.
It works very well unter win xp.
Can any one help with a (alternative) solution?
Thanx
MSG
17th August 2010 10:41 UTC
If the installer is small, you can use the same trick that NSIS uninstallers use: Copy the exe to the temp folder, run that with the original $exepath as a parameter, exit the original exe, and in .onInstSuccess delete the original.
Afrow UK
17th August 2010 11:44 UTC
Don't post another topic.
Stu
adriatik
17th August 2010 11:46 UTC
how is deleted then the copy ... or you still have it in the temp folder...
MSG
17th August 2010 11:50 UTC
Yes, it will be left behind in the temp folder. That's why this should only be used for very small files.
adriatik
17th August 2010 11:52 UTC
nice solution but it is not the one i am looking for. i cannot let the copy into the temp folder. thanks though.
Afrow UK
17th August 2010 12:03 UTC
There isn't really any other way that I can think of. Even SelfDel injects code into a new instance of explorer.exe which waits until it can delete your chosen file. SelfDel will not work on 64-bit because the explorer.exe process is 64-bit and NSIS is not. Unless NSIS becomes 64-bit (which is not any time soon) then you have no choice but to write your own plug-in or executable to act like SelfDel does.
Stu
Animaether
17th August 2010 13:02 UTC
what if you write out a batch file on first installer run that re-runs the installer (with a flag so you can differentiate between initial run and full run), deletes the installer and deletes itself.. run that and exit the initial installer?
batch files can self-destruct.. the parser will complain about the batch file no longer existing, but that's kinda the point?
Afrow UK
17th August 2010 13:21 UTC
You could use a VBS as well which will run hidden and can also delete itself leaving no trace.
Stu
Anders
17th August 2010 13:29 UTC
The SelfDel plugin should be changed and use rundll32.exe and not explorer
Takhir
17th August 2010 18:20 UTC
SelfDel may not work on Vista, 2008, Win7 because of security limitations. And Afrow is right - no way to attach 32-bit thread to 64-bit process.
mrjohn
5th July 2011 12:08 UTC
Hi adriatik,have you found some solution ?
I have the same problem and I tought to create a exe with nsis,pack it in original installer,drop it to TEMP then call it with EXEC command and pass main installer path,something like this :
!include FileFunc.nsh
>!include "WordFunc.nsh"
>Name "Example1"
>OutFile "example1.exe"
>RequestExecutionLevel user
>!insertmacro GetParameters
Section ""
SetAutoClose true
SetOverwrite on
;File example1.nsi
SectionEnd
>Function .onInit
var /GLOBAL cmdLineParams
Push $R0
${GetParameters} $cmdLineParams
StrCmp $cmdLineParams"" lblExit
StrCmp $cmdLineParams"/S" lblExit
${WordReplace} $cmdLineParams "/S" "" "+" $cmdLineParams
IfFileExists"$cmdLineParams" 0 lblExit
sleep 2000
delete $cmdLineParams
lblExit:
>FunctionEnd
>
Is it a good way ?
Thanks !
mrjohn
6th July 2011 12:24 UTC
I've update the code,this works fine on XP
nsh
>!include "WordFunc.nsh"
>Name "dlfile"
>OutFile "dlfile.exe"
>RequestExecutionLevel user
>!insertmacro GetParameters
Section ""
SetAutoClose true
SetOverwrite on
SectionEnd
>Function .onInit
var /GLOBAL cmdLineParams
Push $R0
${GetParameters} $cmdLineParams
StrCmp $cmdLineParams"" lblExit
StrCmp $cmdLineParams"/S" lblExit
${WordReplace} $cmdLineParams "/S" "" "+" $cmdLineParams
Push $cmdLineParams
Call Trim
Pop $cmdLineParams
IfFileExists $cmdLineParams 0 lblExit
sleep 2000
delete $cmdLineParams
lblExit:
>Delete /rebootok $EXEFILE
FunctionEnd
>Function Trim
Exch $R1
Push $R2
Loop:
StrCpy $R2 "$R1" 1
StrCmp"$R2" " " TrimLeft
StrCmp"$R2" "$\r" TrimLeft
StrCmp"$R2" "$\n" TrimLeft
StrCmp"$R2" "$\t" TrimLeft
GoTo Loop2
TrimLeft:
StrCpy $R1 "$R1" "" 1
Goto Loop
Loop2:
StrCpy $R2 "$R1" 1 -1
StrCmp"$R2" " " TrimRight
StrCmp"$R2" "$\r" TrimRight
StrCmp"$R2" "$\n" TrimRight
StrCmp"$R2" "$\t" TrimRight
GoTo Done
TrimRight:
StrCpy $R1 "$R1" -1
Goto Loop2
Done:
Pop $R2
Exch $R1
FunctionEnd
>
usage:
onGUIEnd
Exec 'dlfile.exe /S $EXEFILE'
>FunctionEnd
>
mrjohn
7th July 2011 10:43 UTC
The correct use is to pass $EXEPATH not $EXEFILE
So dropt that exe to $temp and usage is :
SetOutPath "$TEMP"
FILE dlfile.exe
Exec '$TEMP\dlfile.exe /S $EXEPATH'
Afrow UK
7th July 2011 11:31 UTC
Bit of a messy implementation. How about just adding SilentInstall silent to avoid having to use /S (so no need for WordReplace and no UI resource is included either).
Stu
mrjohn
7th July 2011 12:05 UTC
Thanks Afrow UK,done : Attachment 48958
usage :
SetOutPath "$TEMP"
FILE dlfile.exe
Exec '$TEMP\dlfile.exe $EXEPATH'