Skip to content
⌘ NSIS Forum Archive

Windows 7 Start Menu

17 posts

starfighter5#

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#
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#
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#
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
starfighter5#
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#
Originally Posted by starfighter5 View Post
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#
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!
starfighter5#
Which particular code? The one from the pastebin link or the ammendment he posted a few replies back?
starfighter5#
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#
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#
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#
StrCpy $R0 $INSTDIR
ClearErrors
${Do}
RMDir $R0
${IfThen} ${Errors} ${|} ${Break} ${|}
StrCpy $R0 `$R0\..`
${Loop}
Stu