Skip to content

Instantly share code, notes, and snippets.

@JSONOrona
Last active February 1, 2023 20:48
Show Gist options
  • Save JSONOrona/bc561ef35a2636e272f2a501302ec0df to your computer and use it in GitHub Desktop.
Save JSONOrona/bc561ef35a2636e272f2a501302ec0df to your computer and use it in GitHub Desktop.
Name "Chef Client Installation"
OutFile "install-chef-client.exe"
; Constants
!define CHEF_VERSION "16.3.73"
!define CHEF_MSI "chef-client-${CHEF_VERSION}.msi"
; Variables
Var ChefClientInstalled
; Pages
Page Custom CheckChefClientInstalled
Page InstFiles
; Custom page
Function CheckChefClientInstalled
System::Call 'Kernel32::GetModuleHandle(w "chef-client.exe") i .R0'
StrCmp $R0 0 ChefClientNotInstalled ChefClientInstalled
FunctionEnd
; Installation page
Function InstFiles
File "${CHEF_MSI}"
ExecWait 'msiexec /i "${CHEF_MSI}" /qn'
FunctionEnd
; Uninstallation page
Function un.onInit
System::Call 'Kernel32::GetModuleHandle(w "chef-client.exe") i .R0'
StrCmp $R0 0 NoChefClient un.ChefClientInstalled
FunctionEnd
; Labels
Label ChefClientNotInstalled
StrCpy $ChefClientInstalled 0
Goto InstFiles
Label ChefClientInstalled
MessageBox MB_OK "Chef client is already installed."
Abort
Label NoChefClient
MessageBox MB_OK "Chef client is not installed."
Abort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment