[Initial]
Message=Installiere MDG Visual Studio Code...
DefVar $Version$
DefVar $ExitCode$
DefVar $CreateContextMenuEntry$
DefVar $ContextMenuArguments$
DefVar $CreateDesktopShortcut$
DefVar $DesktopShortcutArgument$

[Aktionen]
ShowBitmap "%ScriptPath%\logo.png" "MDG Visual Studio Code"
Sub_GetProperties
Sub_ConfigureProperties
WinBatch_Setup
Sub_HandleExitCode

[Sub_GetProperties]
Set $Version$ = GetValue("productversion", GetProductMap)
Set $CreateContextMenuEntry$ = GetProductProperty("contextmenuentry", False)
Set $CreateContextMenuEntry$ = GetProductProperty("desktopshortcut", False)

[Sub_ConfigureProperties]
if ($CreateContextMenuEntry$ = "True")
  Set $ContextMenuArguments$ = ", !addcontextmenufiles, !addcontextmenufolders"
else
  Set $ContextMenuArguments$ = ""
endif

if ($CreateDesktopShortcut$ = "True")
  Set $DesktopShortcutArgument$ = ", !desktopicon"
else
  Set $DesktopShortcutArgument$ = ""
endif

[WinBatch_Setup]
%ScriptPath%\data\VSCodeSetup-x64-$Version$.exe /VERYSILENT /SUPPRESSMSGBOXES /MERGETASKS="!runcode$ContextMenuArguments$ $DesktopShortcutArgument$" /LOG="%opsiLogDir%\vscode-install.log"

; VERYSILENT unterdrückt das Installationsfenster
; SUPPRESSMSGBOXES unterdrückt Benachrichtigungsfenster
; MERGETASKS verhindert das automatische Starten des Programms nach der Installation

[Sub_HandleExitCode]
; check return code
Set $ExitCode$ = GetLastExitCode
comment "GetLastExitCode: " + $ExitCode$
if not($ExitCode$ = "0")
  LogError "Fatal: setup returned exit code " + $ExitCode$
  IsFatalError
endif
