; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppID={{449374D0-6255-4510-8010-C934A7FBCFF1}
AppName=Scol Java Server
AppVersion=Scol Java Server 1.4
;AppVerName=Scol Java Server 1.4
AppPublisher=Scol-Technologies
AppPublisherURL=http://www.scolring.org
AppSupportURL=http://www.scolring.org
AppUpdatesURL=http://www.scolring.org
DefaultGroupName=Scol Java Server
OutputDir=release
OutputBaseFilename=jscol_setup
SetupIconFile=scol.ico
Compression=lzma/Max
SolidCompression=true
InternalCompressLevel=Max
VersionInfoVersion=1.4
VersionInfoCompany=Scol-Technologies
VersionInfoDescription=Scol Java server
VersionInfoCopyright=Scol-Technologies 2019
MinVersion=0,5.01.2600
AppCopyright=Scol-Technologies 2019
UsePreviousAppDir=false
DefaultDirName={pf}\ScolJavaServer
;sign setup i-maginer "C:\Program Files (x86)\Windows Kits\8.1\bin\x86\signtool" sign /a /t http://timestamp.globalsign.com/scripts/timestamp.dll $f
SignTool=i-maginer

[Languages]
Name: english; MessagesFile: compiler:Default.isl
Name: french; MessagesFile: compiler:Languages\French.isl

[Tasks]

[Files]
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: ..\..\server\ScolJavaServer\install\*; DestDir: {app}; Flags: ignoreversion recursesubdirs; 

[Icons]
Name: {group}\{cm:UninstallProgram,Scol Java Server}; Filename: {uninstallexe}

[Run]

[Registry]

[CustomMessages]

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
  ResultCode: Integer;

begin
	if (CurStep = ssInstall) then
	begin
		// unregister the service
    if (Exec('sc.exe', 'stop "ScolJavaServer"', '', SW_HIDE, ewNoWait, ResultCode)) then begin
		  end;
		if (Exec(ExpandConstant('{app}\jscolService.exe'), '--WinRun4J:UnregisterService', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)) then begin
			// handle success if necessary; ResultCode contains the exit code
			//MsgBox('ok', mbInformation, MB_OK);
		end
		else begin
			// handle failure if necessary; ResultCode contains the error code
			//MsgBox('pas ok', mbInformation, MB_OK);
		end;
	end
  else if (CurStep = ssDone) then
  begin
    // register the service
		if (Exec(ExpandConstant('{app}\jscolService.exe'), '--WinRun4J:RegisterService', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)) then begin
		  //start the service
			if (Exec('sc.exe', 'start "ScolJavaServer"', '', SW_HIDE, ewNoWait, ResultCode)) then begin
		  end;
		end
		else begin
			// handle failure if necessary; ResultCode contains the error code
			//MsgBox('pas ok', mbInformation, MB_OK);
		end;
  end;
end;


procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  ResultCode: Integer;

begin
	if (CurUninstallStep = usUninstall) then
	begin
		// unregister the service
    if (Exec('sc.exe', 'stop "ScolJavaServer"', '', SW_HIDE, ewNoWait, ResultCode)) then begin
		  end;
		if (Exec(ExpandConstant('{app}\jscolService.exe'), '--WinRun4J:UnregisterService', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)) then begin
			// handle success if necessary; ResultCode contains the exit code
			//MsgBox('ok', mbInformation, MB_OK);
		end
		else begin
			// handle failure if necessary; ResultCode contains the error code
			//MsgBox('pas ok', mbInformation, MB_OK);
		end;
	end;
end;