Skip to content

Commit 2d58aac

Browse files
committed
Add CLI args for controlling which shortcuts are created to installer
1 parent 8a8bb3b commit 2d58aac

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

tools/choco_template/tools/chocolateyinstall.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ $pp = Get-PackageParameters
77
if ($pp['StartAfterInstall']) {
88
$silentArgs += ' /StartAfterInstall'
99
}
10+
if ($pp['DesktopShortcut']) {
11+
$silentArgs += ' /DesktopShortcut'
12+
}
13+
if ($pp['StartMenuShortcut']) {
14+
$silentArgs += ' /StartMenuShortcut'
15+
}
1016

1117
$packageArgs = @{
1218
packageName = $env:ChocolateyPackageName

tools/installer.nsi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ UninstPage uninstConfirm
5555
UninstPage instfiles
5656

5757

58+
Var Parameters
5859
Var StartMenuShortcut
5960
Var DesktopShortcut
6061

@@ -81,9 +82,14 @@ Function ShortcutPageLeave
8182
FunctionEnd
8283

8384

84-
Function checkLaunchParam
85-
${GetParameters} $0
85+
Function getParams
86+
${GetParameters} $Parameters
8687
ClearErrors
88+
FunctionEnd
89+
90+
91+
Function checkLaunchParam
92+
Call getParams
8793
${GetOptions} $0 "/StartAfterInstall" $1
8894
${IfNot} ${Errors}
8995
Exec "$INSTDIR\${PRODUCT}.exe"
@@ -122,12 +128,18 @@ Section "Installer"
122128
; Run on startup
123129
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "RestoreWindowPos" '"$InstDir\${PRODUCT}.exe"'
124130

131+
Call getParams
132+
125133
; Add start menu shortcut if option enabled
134+
${GetOptions} $Parameters "/StartMenuShortcut" $1
126135
${IF} $StartMenuShortcut <> 0
136+
${OrIfNot} ${Errors}
127137
createShortCut "$SMPROGRAMS\${PRODUCT}.lnk" "$INSTDIR\${PRODUCT}.exe" "--open-gui" "" "" SW_SHOWNORMAL
128138
${ENDIF}
129139

140+
${GetOptions} $Parameters "/DesktopShortcut" $1
130141
${IF} $DesktopShortcut <> 0
142+
${OrIfNot} ${Errors}
131143
createShortCut "$DESKTOP\${PRODUCT}.lnk" "$INSTDIR\${PRODUCT}.exe" "--open-gui" "" "" SW_SHOWNORMAL
132144
${ENDIF}
133145

0 commit comments

Comments
 (0)