您的位置:首页 > 其它

NSIS不能删除其打包的程序桌面快捷方式的解决方式

2010-03-22 23:24 627 查看
实质上就是权限的问题,可以模仿如下方式处理

Windows Vista and Windows 7 automatically identifies installer executables,
including NSIS installers, and asks the user permission to run them with
elevated privileges. Automatic detection, however, comes with the price of
automatic backward compatibility tricks. One of which is automatic relocation of
shortcuts created in the Start Menu to All Users' Start Menu.

To workaround this, use the new RequestExecutionLevel command or create the
shortcuts in All Users' folders in the first place, using
SetShellVarContext.

OutFile vista.exe
Name Vista

RequestExecutionLevel user

Section
CreateDirectory "$SMPROGRAMS/Vista Test"
CreateShortcut  "$SMPROGRAMS/Vista Test/hello.lnk" $WINDIR/notepad.exe
WriteUninstaller $EXEDIR/uninst.exe
SectionEnd

Section uninstall
Delete "$SMPROGRAMS/Vista Test/hello.lnk"
RMDir "$SMPROGRAMS/Vista Test"
SectionEnd

OutFile vista.exe
Name Vista

RequestExecutionLevel admin #NOTE: You still need to check user rights with UserInfo!

Function .onInit
#TODO: call UserInfo plugin to make sure user is admin
FunctionEnd

Section
SetShellVarContext all
CreateDirectory "$SMPROGRAMS/Vista Test"
CreateShortcut  "$SMPROGRAMS/Vista Test/hello.lnk" $WINDIR/notepad.exe
WriteUninstaller $EXEDIR/uninst.exe
SectionEnd

Section uninstall
SetShellVarContext all
Delete "$SMPROGRAMS/Vista Test/hello.lnk"
RMDir "$SMPROGRAMS/Vista Test"
SectionEnd

原文链接:http://nsis.sourceforge.net/Shortcuts_removal_fails_on_Windows_Vista
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: