#define MyAppName "Grabber Config" #define MyAppVersion "1.0.0" #define MyAppPublisher "Patrick Gniza" #define MyAppExeName "GrabberConfig.exe" [Setup] AppId={{8B2E6B6B-5E0B-4C7F-BF71-GRABBER-CONFIG}} AppName={#MyAppName} AppVersion={#MyAppVersion} AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} DefaultDirName={autopf}\Grabber Config DefaultGroupName= DisableProgramGroupPage=yes DisableDirPage=no DisableReadyPage=no DisableFinishedPage=no DisableWelcomePage=no ShowLanguageDialog=no OutputBaseFilename=GrabberConfigSetup OutputDir=build Compression=lzma SolidCompression=yes ArchitecturesInstallIn64BitMode=x64compatible PrivilegesRequired=admin LicenseFile=LICENSE SetupIconFile=GrabberConfig.ico UninstallDisplayIcon={app}\{#MyAppExeName} [Languages] Name: "german"; MessagesFile: "compiler:Languages\German.isl" [Tasks] Name: "autostart"; \ Description: "Grabber Config zum Autostart hinzufügen"; \ GroupDescription: "Zusätzliche Aufgaben:"; \ Flags: unchecked [Files] Source: "build\GrabberConfig.dist\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs [Icons] Name: "{commonstartup}\Grabber Config"; \ Filename: "{app}\{#MyAppExeName}"; \ Tasks: autostart [Run] Filename: "{app}\{#MyAppExeName}"; \ Parameters: "/config"; \ Description: "Grabber Config Konfiguration starten"; \ Flags: nowait postinstall skipifsilent [UninstallRun] Filename: "taskkill"; \ Parameters: "/F /IM {#MyAppExeName}"; \ Flags: runhidden waituntilterminated [UninstallDelete] Type: filesandordirs; Name: "{app}" [Code] procedure InitializeWizard; begin if FileExists(WizardDirValue + '\{#MyAppExeName}') then begin WizardForm.NextButton.Caption := '&Update'; WizardForm.WelcomeLabel1.Caption := 'Update von Grabber Config'; WizardForm.WelcomeLabel2.Caption := 'Die bestehende Installation wird aktualisiert.'; end; end; procedure CleanApplicationDirectory(); var FindRec: TFindRec; Path: String; begin Path := ExpandConstant('{app}'); if FindFirst(Path + '\*', FindRec) then begin try repeat if (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then begin DelTree(Path + '\' + FindRec.Name, True, True, True); end else begin DeleteFile(Path + '\' + FindRec.Name); end; end; until not FindNext(FindRec); finally FindClose(FindRec); end; end; end; procedure CurStepChanged(CurStep: TSetupStep); var ResultCode: Integer; begin if CurStep = ssInstall then begin Exec( 'taskkill', '/F /IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode ); CleanApplicationDirectory(); end; end;