Skip to content
⌘ NSIS Forum Archive

SelfDel plugin crashes on Win7 64Bit

16 posts

adriatik#

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#
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.
MSG#
Yes, it will be left behind in the temp folder. That's why this should only be used for very small files.
adriatik#
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#
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#
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#
You could use a VBS as well which will run hidden and can also delete itself leaving no trace.

Stu
Takhir#
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#edited
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#
I've update the code,this works fine on XP

!include FileFunc.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:
Function .onGUIEnd
  Exec 'dlfile.exe /S $EXEFILE'
FunctionEnd 
mrjohn#
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#
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#
Thanks Afrow UK,done : dlfile.nsi

usage :
 SetOutPath "$TEMP"
    FILE dlfile.exe
    Exec '$TEMP\dlfile.exe $EXEPATH'