Shortcuts removal fails on Windows Vista: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (better FAQ category) |
(Made examples more correct (and complicated)) |
||
Line 6: | Line 6: | ||
Name Vista | Name Vista | ||
RequestExecutionLevel | RequestExecutionLevel user | ||
Section | Section | ||
Line 20: | Line 20: | ||
<highlight-nsis>OutFile vista.exe | <highlight-nsis>OutFile vista.exe | ||
Name Vista | Name Vista | ||
Function .onInit | |||
#TODO: call UserInfo plugin to make sure user is admin | |||
FunctionEnd | |||
Section | Section |
Revision as of 19:05, 1 October 2009
Windows Vista 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 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 Function .onInit #TODO: call UserInfo plugin to make sure user is admin FunctionEnd Section SetShellVarContext all 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