NSIS 打包 win7 中无法删除快捷方式

NSIS打包的安装程序,在Vista中的安装过程中如果向开始菜单添加了快捷方式的话,在卸载时卸载程序会不能正常删除这些快捷方式。

这 主要是因为Vista中使用UAC控制用户的权限。

我们使用NSIS打包程序一般会配套使用相应的脚本编辑器,比如HM NIS Edit,或者国内高手对HM NIS Edit进行源代码级增量改进之后的HM VNIS Edit,但是这两个软件都已经很久没有更新了,在使用向导创建开发脚本时,不会注意到使用Vista系统引起的问题,所以如果你使用上述两个脚本编辑器 生成脚本的话,就会出现这样的问题。

其实NSIS本身不存在什么问题,它提供了新的函数 RequestExecutionLevel语句(自2.21版添加),针对Vista的UAC进行权限请求,你只需在脚本中添加:

RequestExecutionLevel none|user|highest|admin

常 规安装程序只需user权限就可以解决上述问题了。

其他的解决方案:

使用SetShellVarContext all 将快捷方式创建到alluser的开始菜单中,但是感觉这样治标不治本。

参考自nsis官方文档:Shortcuts removal fails on Windows Vista

From NSIS Wiki

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 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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值