Vista/Win7系统,如何删除NSIS脚本生成的快捷方式?

来源:互联网 发布:ubuntu 如何看分区 编辑:程序博客网 时间:2024/05/08 10:07

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.exeName Vista RequestExecutionLevel user Section  CreateDirectory "$SMPROGRAMS\Vista Test"  CreateShortcut  "$SMPROGRAMS\Vista Test\hello.lnk" $WINDIR\notepad.exe  WriteUninstaller $EXEDIR\uninst.exeSectionEnd Section uninstall  Delete "$SMPROGRAMS\Vista Test\hello.lnk"  RMDir "$SMPROGRAMS\Vista Test"SectionEnd
OutFile vista.exeName Vista RequestExecutionLevel admin #NOTE: You still need to check user rights with UserInfo! Function .onInit#TODO: call UserInfo plugin to make sure user is adminFunctionEnd Section  SetShellVarContext all  CreateDirectory "$SMPROGRAMS\Vista Test"  CreateShortcut  "$SMPROGRAMS\Vista Test\hello.lnk" $WINDIR\notepad.exe  WriteUninstaller $EXEDIR\uninst.exeSectionEnd Section uninstall  SetShellVarContext all  Delete "$SMPROGRAMS\Vista Test\hello.lnk"  RMDir "$SMPROGRAMS\Vista Test"SectionEnd