Old 17th August 2010, 09:15   #1
adriatik
Junior Member
 
Join Date: Jun 2010
Posts: 3
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
adriatik is offline   Reply With Quote
Old 17th August 2010, 09:41   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
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 is offline   Reply With Quote
Old 17th August 2010, 10:44   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Don't post another topic.

Stu
Afrow UK is offline   Reply With Quote
Old 17th August 2010, 10:46   #4
adriatik
Junior Member
 
Join Date: Jun 2010
Posts: 3
how is deleted then the copy ... or you still have it in the temp folder...
adriatik is offline   Reply With Quote
Old 17th August 2010, 10:50   #5
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Yes, it will be left behind in the temp folder. That's why this should only be used for very small files.
MSG is offline   Reply With Quote
Old 17th August 2010, 10:52   #6
adriatik
Junior Member
 
Join Date: Jun 2010
Posts: 3
nice solution but it is not the one i am looking for. i cannot let the copy into the temp folder. thanks though.
adriatik is offline   Reply With Quote
Old 17th August 2010, 11:03   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 17th August 2010, 12:02   #8
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
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?
Animaether is offline   Reply With Quote
Old 17th August 2010, 12:21   #9
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You could use a VBS as well which will run hidden and can also delete itself leaving no trace.

Stu
Afrow UK is offline   Reply With Quote
Old 17th August 2010, 12:29   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,504
The SelfDel plugin should be changed and use rundll32.exe and not explorer

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 17th August 2010, 17:20   #11
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
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.
Takhir is offline   Reply With Quote
Old 5th July 2011, 11:08   #12
mrjohn
Member
 
Join Date: Feb 2009
Posts: 69
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 :

PHP Code:
!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 
"$cmdLineParams0 lblExit
    sleep 2000
    delete $cmdLineParams
      
lblExit
:
FunctionEnd 
Is it a good way ?
Thanks !

Last edited by mrjohn; 5th July 2011 at 12:55.
mrjohn is offline   Reply With Quote
Old 6th July 2011, 11:24   #13
mrjohn
Member
 
Join Date: Feb 2009
Posts: 69
I've update the code,this works fine on XP

PHP Code:
!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 "$R11
    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
    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:
PHP Code:
Function .onGUIEnd
  Exec 
'dlfile.exe /S $EXEFILE'
FunctionEnd 
mrjohn is offline   Reply With Quote
Old 7th July 2011, 09:43   #14
mrjohn
Member
 
Join Date: Feb 2009
Posts: 69
The correct use is to pass $EXEPATH not $EXEFILE
So dropt that exe to $temp and usage is :
PHP Code:
 SetOutPath "$TEMP"
    
FILE dlfile.exe
    Exec 
'$TEMP\dlfile.exe /S $EXEPATH' 
mrjohn is offline   Reply With Quote
Old 7th July 2011, 10:31   #15
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 7th July 2011, 11:05   #16
mrjohn
Member
 
Join Date: Feb 2009
Posts: 69
Thanks Afrow UK,done : dlfile.nsi

usage :
PHP Code:
 SetOutPath "$TEMP"
    
FILE dlfile.exe
    Exec 
'$TEMP\dlfile.exe $EXEPATH' 
mrjohn is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump