![]() |
#1 |
Junior Member
Join Date: Apr 2013
Posts: 3
|
FileCopy Fail on Windows ServerCore
Hi, I am making an installer with NSIS.
I have come across a strange behaviour on Windows ServerCore What I am doing is in an upgrade situation, I am copying the existing configuration files to the $TEMP directory. Then I do an install of the new files. After that I copy the configuration from $TEMP back into InstDir. This works fine on Windows7, but on ServerCore I am getting file copy errors. To try to get some error message back from the Copy, I used cmd to copy the files, and then, that worked! So using the DOS copy command works, but CopyFiles doesnt. Any Ideas why? code: |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Have you tried using $PLUGINSDIR instead?
Stu |
![]() |
![]() |
![]() |
#3 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Copyfiles uses SHFileOperation internally, it is not listed on http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx not sure if that means it is not going to work...
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Apr 2013
Posts: 3
|
CopyFiles is 'core' NSIS functionality? Can I get a definitive answer if it is expected to work?
I guess I can us my DOS hack to get by, but I'd rather use proper functions. |
![]() |
![]() |
![]() |
#5 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
SHFileOperation has been a part of Windows since Windows95 which is why NSIS uses it as the workhorse of the CopyFiles instruction. What MS defines as core 15 years later is not really under our control...
You could call the low level version with: System::Call 'kernel32::CopyFile(t "c:\file.ext", t "c:\newfile.ext", i 0)i.r0' and $0 will be 0 on errors IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#6 |
Junior Member
Join Date: Apr 2013
Posts: 3
|
that kernel32::CopyFile works. Thanks a million.
No idea why, I use a lot of CopyFile calls, and most work, except those two. They are copying into ProgramFiles, that might be linked...though I installed into C:\<MyFolder> and had the same issue. but...its working. Thanks again for the prompt replies. |
![]() |
![]() |
![]() |
#7 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
If some of the CopyFile calls work they should all work, this sounds very weird...
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#8 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Could it be a CopyFiles popup that is causing the copy to fail (i.e. try using /silent)? I guess you could try with a large file to find out.
Stu |
![]() |
![]() |
![]() |
#9 |
Senior Member
Join Date: Feb 2005
Location: London
Posts: 218
|
Hi,
Hope I'm not butting in ... You can ignore this. It occurs to me that to disable the log text "Copy to:" and "Copy failed" when you use CopyFiles, 'kernel32::CopyFile' is a solution. Pop $0 to see if copying succeeded or failed and insert custom log text. You don't have to resort to SetDetailsPrint none. Just an obversation I'd make. I don't know what's causing CopyFiles to not work. |
![]() |
![]() |
![]() |
#10 |
Senior Member
Join Date: Feb 2005
Location: London
Posts: 218
|
Speaking of weird -- I'm copying a group of small files, some of which are locked.
code: The log output gives me something entirely weird: PHP Code:
Luckily CopyFiles does work. I'm on Windows 7. I think you may have to Push and Exch in order to fix 'kernel32::CopyFile'. I'm too lazy to give it a go. |
![]() |
![]() |
![]() |
#11 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Who told you to pop? If you want to pop then the system code should end with ...)i.s'
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#12 |
Senior Member
Join Date: Feb 2005
Location: London
Posts: 218
|
Yes, it works perfectly. Thanks. Without Pop.
![]() It seems a lot faster than CopyFiles. I use the error code to pop up a message. A lot faster with many messages. Is there no drawback, like that it would not run silently, when you copy large files? I know it probably does run silently, but if there's the slightest chance of a window popping up, ... Thank you very much indeed, Anders. |
![]() |
![]() |
![]() |
#13 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
CopyFiles uses the same copy engine as Explorer, kernel32::CopyFile is a much more low level copy and should never display anything when called from NSIS
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|