Skip to content
⌘ NSIS Forum Archive

move dll file from source to destination on reboot

17 posts

shekara#

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
Anders#
System::Call "kernel32::MoveFileEx(t 'C:\Temp\test.dll', t 'D:\test\test.dll', i 5)i.r0?e"
Pop $1
MessageBox mb_ok $0,$1 
What does the messagebox say?

Remember that you must run as elevated administrator for reboot renaming to work...
Anders#
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?
shekara#
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
shekara#
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
Anders#
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?
shekara#
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"
Anders#
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...
shekara#
$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
Anders#
My only suggestion is to avoid cross-volume operations, do:

File "/oname=$proddir\events.tmp" "..\..\bld\nsis\events.dll"
SetFileAttributes "$proddir\events.dll" FILE_ATTRIBUTE_NORMAL
Rename /REBOOTOK "$proddir\events.tmp" "$PRODDIR\events.dll"
shekara#
you made my day..thanks much for this wonderful suggestion. it works, even though I don't understand the rationality behind this. thank you
Anders#
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.