Old 1st June 2021, 13:37   #1
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
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
shekara is offline   Reply With Quote
Old 1st June 2021, 14:07   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
PHP Code:
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,$
What does the messagebox say?

Remember that you must run as elevated administrator for reboot renaming to work...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 1st June 2021, 14:47   #3
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
it shows 1,127
shekara is offline   Reply With Quote
Old 1st June 2021, 21:52   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
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
Anders is offline   Reply With Quote
Old 9th June 2021, 14:15   #5
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
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 is offline   Reply With Quote
Old 9th June 2021, 22:49   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
Again, which file are you actually trying to replace? Give us the real name...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th June 2021, 01:54   #7
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
the dll does make note of event handling. events.dll
shekara is offline   Reply With Quote
Old 10th June 2021, 03:08   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
Please try Process Monitor boot logging feature

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th June 2021, 18:18   #9
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
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
shekara is offline   Reply With Quote
Old 11th June 2021, 19:56   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
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
Anders is offline   Reply With Quote
Old 12th June 2021, 03:07   #11
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
windows 64 bit
shekara is offline   Reply With Quote
Old 12th June 2021, 03:09   #12
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
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"
shekara is offline   Reply With Quote
Old 12th June 2021, 03:56   #13
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
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
Anders is offline   Reply With Quote
Old 12th June 2021, 07:30   #14
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
$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
shekara is offline   Reply With Quote
Old 13th June 2021, 00:49   #15
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
My only suggestion is to avoid cross-volume operations, do:

Quote:
File "/oname=$proddir\events.tmp" "..\..\bld\nsis\events.dll"
SetFileAttributes "$proddir\events.dll" FILE_ATTRIBUTE_NORMAL
Rename /REBOOTOK "$proddir\events.tmp" "$PRODDIR\events.dll"

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th June 2021, 12:45   #16
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
you made my day..thanks much for this wonderful suggestion. it works, even though I don't understand the rationality behind this. thank you
shekara is offline   Reply With Quote
Old 13th June 2021, 15:16   #17
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
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
Anders 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