- NSIS Discussion
- Windows 7 Start Menu
Archive: Windows 7 Start Menu
starfighter5
6th January 2011 11:28 UTC
Windows 7 Start Menu
I thought my installer was working correctly but I have just noticed some strange behaviour in Windows 7
If I install it as a user it allows me to uninstall fine, removes the startmenu items. But if I install as an admin and try and uninstall as a user it asks me to elevate and then leaves the icons in the start menu.
Which plugin or example should I be looking at the resolve my Windows 7 issues?
starfighter5
6th January 2011 14:17 UTC
My installer is real simple, It just dumps some files into a folder in Program Files and doesn't use any registry entries at all.
I have added this section
Section
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\mypack"
CreateShortCut "$SMPROGRAMS\mypack\myprog.lnk" "$INSTDIR\myprog.exe"
CreateShortCut "$DESKTOP\myprog.lnk" "$INSTDIR\myprog.exe"
SectionEnd
As far as I am aware this should create the Start Menu items and the Desktop icon for all users, but it is not :(
Am I doing things right?
MSG
6th January 2011 14:45 UTC
Use requestexecutionlevel admin to request admin access in the manifest, and then use userInfo::getAccountType in .onInit and un.onInit to verify that you have admin access.
starfighter5
6th January 2011 15:14 UTC
Are there any more arguments to use with...
Function .oninit
userInfo::getAccountType
FunctionEnd
and
Function un.onInit
userInfo::getAccountType
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
Anders
6th January 2011 19:15 UTC
Yes, you actually need to check the result, http://nsis.pastebin.com/63tS3AS2
starfighter5
10th January 2011 13:24 UTC
After much messing I have decided to go with the template you created a while ago at http://www.nsis.pastebin.com/PmiY8DuZ
This works for me and resolves the issue I have been having, only one more problem though I was wondering if you could help with.
I wanted to have a pre-defined Start Menu folder, currently when you get to the Start Menu page is just displays 'Product Name'
I want it to automatically display 'Company Name/Product Name'
I have messed about with MUI_STARTMENUPAGE_DEFAULTFOLDER but this just seems to break the installer, can you point me in the right direction?
Anders
10th January 2011 13:42 UTC
Originally posted by starfighter5
I have messed about with MUI_STARTMENUPAGE_DEFAULTFOLDER but this just seems to break the installer, can you point me in the right direction?
Break how? ( / could be a problem, try \ )
The only problem with nested folders is deleting them.
If I add !define MUI_STARTMENUPAGE_DEFAULTFOLDER "test\test2" to the top of my script, it works fine, but I need
${If} $SMDir != ""
###TODO: Delete "$SMPrograms\$SMDir\${APPNAME}.lnk"
ClearErrors
${Do}
RMDir "$SMPrograms\$SMDir"
StrCpy $SMDir "$SMDir\.."
${IfThen} ${Errors} ${|} ${Break} ${|}
${Loop}
${EndIf}
to delete the folders
starfighter5
10th January 2011 15:14 UTC
All working now, thanks for all the help :)
starfighter5
11th January 2011 10:09 UTC
I've just spotted one last issue, because I have set the folder using....
!define MULTIUSER_INSTALLMODE_INSTDIR "Company Name\Product Name\Version"
When it comes to uninstalling, RMDir "$INSTDIR" only seems to delete the Version folder, the Company Name\ Product Name folder stays
Help!
Afrow UK
11th January 2011 12:18 UTC
Use the same code that Anders posted for that too.
Stu
starfighter5
11th January 2011 12:56 UTC
Which particular code? The one from the pastebin link or the ammendment he posted a few replies back?
starfighter5
11th January 2011 13:41 UTC
So am I right in thinking I can just add to this section instead of creating a whole new one for INSTdir?
!insertmacro ReadUninstData $SMDir SMDir
${If} $SMDir != ""
###TODO: Delete "$SMPrograms\$SMDir\${APPNAME}.lnk"
Delete "$SMPrograms\$SMDir\${APPNAME}.lnk"
Delete "$SMPrograms\$SMDir\Uninstall.lnk"
Delete "$DESKTOP\programlink.lnk"
ClearErrors
${Do}
RMDir "$SMPrograms\$SMDir"
StrCpy $SMDir "$SMDir\.."
${IfThen} ${Errors} ${|} ${Break} ${|}
${Loop}
${EndIf}
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGUINSTKEY}"
Delete "$INSTDIR\uninstall.exe"
RMDir "$INSTDIR"
RMDir "$PROGRAMFILES\Company Name\Product Name"
RMDir "$PROGRAMFILES\Company Name"
messageBox MB_OK "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
SectionEnd
Afrow UK
11th January 2011 14:25 UTC
You could do it that way but that's not recursive. If you change $INSTDIR your code will no longer work. Up to you really.
Stu
starfighter5
11th January 2011 14:43 UTC
Sorry to sound daft but I am struggling to adapt that code to work for the Current User install directory instead of SMDir which it currently does
Afrow UK
11th January 2011 16:11 UTC
StrCpy $R0 $INSTDIR
ClearErrors
${Do}
RMDir $R0
${IfThen} ${Errors} ${|} ${Break} ${|}
StrCpy $R0 `$R0\..`
${Loop}
Stu
starfighter5
11th January 2011 16:26 UTC
Thanks for that, everything seems to be working!
Anders
11th January 2011 18:11 UTC
I updated the samples with a general function for this, get it from http://sn.im/1tmfzt