![]() |
#1 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
move dll file from source to destination on reboot
i want to move a dll from source to destination on a reboot. i have tried
SetOverwrite on Rename /REBOOTOK "C:\Temp\test.dll" "D:\test\test.dll" ; Didnt work System::Call "kernel32::MoveFileEx(t 'C:\Temp\test.dll', t 'D:\test\test.dll', i 5)" ; Didnt work Tried InstallLib..nothing seems to work |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
PHP Code:
Remember that you must run as elevated administrator for reboot renaming to work... IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
it shows 1,127
|
![]() |
![]() |
![]() |
#4 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
1 means success.
It is very annoying when you ask the same question on Stackoverflow but provide slightly different information there. Which file are you actually trying to replace? IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
i am sorry delay reply. i am trying to replace a dll . when i use system call, even though it shows success as per return code, it is actually not moving the file. i did compare it using fc cmd. the same applies when i use rename nsis fn. prior to restart , it sets pending rename operation key in registry and post restart file key is deleted. but again file is not moved
|
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Again, which file are you actually trying to replace? Give us the real name...
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#7 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
the dll does make note of event handling. events.dll
|
![]() |
![]() |
![]() |
#8 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Please try Process Monitor boot logging feature
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#9 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
this will be one of the most annoying issue i have ever seen. boot log says it is completed successfully. however if i compare files using fc between my source and destination, it says bth are different files. this is for rename fn.
for system call, result pending file name operations not found error... not sure why this is seen |
![]() |
![]() |
![]() |
#10 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Rename /rebootok ends up as MoveFileEx(pszExisting, pszNew, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING); so I don't understand how the behavior would be different from the System::Call.
Which Windows version does it fail on? 64-bit? IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#11 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
windows 64 bit
|
![]() |
![]() |
![]() |
#12 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
my code is as simple as this
SetOverwrite on SetOutPath "$TEMP" ${Logit} "Copying events dll to $TEMP folder" File "/oname=$TEMP\events.tmp" "..\..\bld\nsis\events.dll" /* OPTIONAL SetFileAttributes "events_hooks_lib.dll" FILE_ATTRIBUTE_NORMAL ClearErrors */ Rename /REBOOTOK "$TEMP\events.tmp" "$PRODDIR\events.dll" |
![]() |
![]() |
![]() |
#13 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Is $PRODDIR inside Program files (x86)? What if you set it to c:\test?
What if you extract events.tmp to $PRODDIR before the rename? SetFileAttributes call is missing full path... IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#14 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
$PRODDIR is a separate partition where OS is not installed. even if I set SetFileAttributes full path is does not make any difference.
I can extract before rename and it works. currently, that is the approach. but sometimes the file gets locked and my installation fails. to overcome this I want to install files post-reboot |
![]() |
![]() |
![]() |
#15 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
My only suggestion is to avoid cross-volume operations, do:
Quote:
IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#16 |
Junior Member
Join Date: Oct 2020
Posts: 47
|
you made my day..thanks much for this wonderful suggestion. it works, even though I don't understand the rationality behind this. thank you
|
![]() |
![]() |
![]() |
#17 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Putting it in the same folder from the beginning avoids any cross-volume issues AND it makes sure the ACL is inherited from the correct parent.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|