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

实质上就是权限的问题,可以模仿如下方式处理

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值