FileCopy of NSIS installer not working in Windows 7 but working in Windows XP

天涯浪子 提交于 2019-12-11 15:24:54

问题


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\'

回答1:


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

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 just calls SHFileOperation, but there could be some breaking changes between XP and Vista+ of course...



来源:https://stackoverflow.com/questions/5959585/filecopy-of-nsis-installer-not-working-in-windows-7-but-working-in-windows-xp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!