Shortcuts removal fails on Windows Vista

转载:http://nsis.sourceforge.net/Shortcuts_removal_fails_on_Windows_Vista

Shortcuts removal fails on Windows Vista

From NSIS Wiki

Windows Vista and Windows 7 automatically identify installer executables, including NSIS installers, and ask 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 the 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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值