2012-06-20 75 views
1

我有了開始菜單的NSIS安裝文件夾硬編碼使用此代碼...NSIS安裝程序開始菜單目錄

Var SMDir ;Start menu folder 
!insertmacro MUI_PAGE_STARTMENU 0 $SMDir 

Section -StartMenu 
    !insertmacro MUI_STARTMENU_WRITE_BEGIN 0 
    CreateDirectory "$SMPrograms\MY Program\My Folder" 
    CreateShortCut "$DESKTOP\My Program" "$INSTDIR\start.exe" 
    CreateShortCut "$SMPROGRAMS\MY Program\My Shortcut.lnk" "$INSTDIR\start.exe" 
    CreateShortCut "$SMPROGRAMS\My Program\Uninstall.lnk" "$INSTDIR\uninstall.exe" 

這一切都從「選擇開始菜單文件夾」它不分開工作不要讓我改變默認的安裝目錄。

有沒有辦法解決這個問題,或者我怎樣才能跳過這個頁面,但仍然會觸發StartMenu部分?

回答

1

如果您不想要startmenu選擇頁面,只需在-StartMenu部分刪除!insertmacro MUI_PAGE_STARTMENU ...和兩個!insertmacro MUI_STARTMENU_*宏。

如果你想允許用戶選擇目錄,則必須使用變量,而不是硬編碼路徑:

outfile test.exe 
name "SM Test" 
requestexecutionlevel user ;Single user/"Just me" installer 

!define MUI_COMPONENTSPAGE_NODESC 
!include mui2.nsh 

Var SMDir ;Start menu folder 
!insertmacro MUI_PAGE_COMPONENTS 
;!define MUI_STARTMENUPAGE_DEFAULTFOLDER "MY Program" ;Default, name is used if not defined 
!insertmacro MUI_PAGE_STARTMENU 0 $SMDir 
!insertmacro MUI_PAGE_INSTFILES 
!insertmacro MUI_LANGUAGE English 


Section -StartMenu 
!insertmacro MUI_STARTMENU_WRITE_BEGIN 0 ;This macro sets $SMDir and skips to MUI_STARTMENU_WRITE_END if the "Don't create shortcuts" checkbox is checked... 
CreateDirectory "$SMPrograms\$SMDir" 
CreateShortCut "$SMPROGRAMS\$SMDir\Myapp.lnk" "$INSTDIR\start.exe" 
!insertmacro MUI_STARTMENU_WRITE_END 
SectionEnd 

Section "Desktop Shortcut" 
CreateShortCut "$DESKTOP\Myapp.lnk" "$INSTDIR\start.exe" 
SectionEnd 

(如果要安裝作爲管理員,那麼你應該訪問$ SMPROGRAMS之前調用SetShellVarContext all你應該不會創建桌面快捷方式)

+0

安德斯救援再次:)謝謝 – fightstarr20