问题描述
我正在使用NSIS安装程序的FileCopy将文件夹及其所有子文件从源复制到目标.这适用于XP,但不适用于Windows7.当我在Windows 7上运行安装程序时,FileCopy对话框甚至没有出现,只是被跳过了.但是在Windows XP中,它会正确显示正在复制文件"对话框并成功.有什么问题?请帮忙.
I am using FileCopy of NSIS installer to copy a folder along with its all subfiles from a source to destination. This works on XP but not on Windows 7. When i run the installer on Windows 7 , then the FileCopy dialog doesn't even appears, it is just skipped out.But in Windows XP, it properly shows the dialog box of "Copying Files" and succeeds.What's the problem? Please help.
!define FileCopy `!insertmacro FileCopy`
!macro FileCopy FilePath TargetDir
CreateDirectory `${TargetDir}`
CopyFiles `${FilePath}` `${TargetDir}`
!macroend
${FileCopy} 'C:\ACCBK\*.*' '$INSTDIR\ACCBK\'
推荐答案
要确保安装程序以admin身份运行,请使用以下代码:
To make sure the installer runs as admin, use this code:
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
!include LogicLib.nsh
Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
如果这是问题所在,则意味着它实际上也在XP(实际上是任何版本的NT)上都被破坏了,您只是忘了以非管理员身份进行测试.
If this is the problem, it means it was actually broken on XP as well (Any version of NT really), you just forgot to test as non-admin.
CopyFiles仅调用SHFileOperation,但是XP和Vista +之间当然可能会有一些重大更改...
CopyFiles just calls SHFileOperation, but there could be some breaking changes between XP and Vista+ of course...
这篇关于NSIS安装程序的FileCopy无法在Windows 7中运行,但可以在Windows XP中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!