Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Пользователь


Сообщения: 53
Благодарности: 0

Профиль | Сайт | Отправить PM | Цитировать


уже проверил)))
только у меня все же есть вопросы по удалению(((
как мне прикрутить удаление к установке так, чтоб пользователь не заметил разницы?
вот скрипт установки
Код: Выделить весь код
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Synergy Center"
#ifndef MyAppVer
	#define MyAppVer "2.4"
#endif
#ifndef MyAppPatch
	#define MyAppPatch "11"
#endif
#ifndef MyAppBuild
	#define MyAppBuild "0"
#endif
#define MyAppPublisher ""

#define MyAppURL ""
#define InstalledLocalURL "http://localhost"

[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={{903E5749-D9EC-45A3-A5E1-B0621695F680}
AppName={#MyAppName}
AppVerName={#MyAppName} {#MyAppVer}.{#MyAppPatch}
VersionInfoVersion={#MyAppVer}.{#MyAppPatch}.{#MyAppBuild}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=D:\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputDir={#MyOutputDir}
UpdateUninstallLogAppName=no
UsePreviousAppDir=yes
CreateUninstallRegKey=no
;DisableDirPage=yes

OutputBaseFilename=Synergy Center {#MyAppVer}.{#MyAppPatch}
Compression=lzma
SolidCompression=yes
WizardImageFile=wizard\WizModernImage-IS.bmp
WizardSmallImageFile=wizard\WizModernSmallImage-IS.bmp

[Languages]
Name: ru; MessagesFile: i18n\Russian.isl,i18n\sc_russian.isl; LicenseFile: dontcopy\license_ru.rtf
Name: ua; MessagesFile: i18n\Ukrainian-6-5.1.11.isl,i18n\sc_ukrainian.isl; LicenseFile: dontcopy\license_ua.rtf

[Registry]
Root: HKLM; Subkey: Software\IVTBelGU\Synergy Center; ValueType: string; ValueName: Version; ValueData: {#MyAppVer}.{#MyAppPatch}; Check: Run_B; Flags: uninsdeletekey

[Dirs]
Name: {app}\apache-tomcat; Flags: uninsneveruninstall; Check: Run_B; Languages: 
Name: {app}\files; Flags: uninsneveruninstall; Check: Run_B; Languages: 
Name: {app}\nginx; Flags: uninsneveruninstall; Check: Run_B; Languages: 
Name: {app}\dbinit; Flags: uninsneveruninstall; Check: Run_B; Languages: 
Name: {app}\backups; Flags: uninsneveruninstall; Check: Run_B; Languages: 
Name: {app}\db_update; Flags: uninsneveruninstall; Check: Run_A; Languages: 
Name: {app}\backups; Flags: uninsneveruninstall; Check: Run_A; Languages: 
[InstallDelete]
Name: {app}\apache-tomcat\bin\service.bat; Type: filesandordirs; Check: Run_A; BeforeInstall: StopTomcat
Name: {app}\apache-tomcat\work\*; Type: filesandordirs; Check: Run_A; BeforeInstall: StopTomcat
Name: {app}\apache-tomcat\webapps\ROOT\WEB-INF\classes\su\*; Type: filesandordirs; Check: Run_A; BeforeInstall: StopTomcat
Name: {app}\apache-tomcat\webapps\ROOT\WEB-INF\classes\i18n\*; Type: filesandordirs; Check: Run_A; BeforeInstall: StopTomcat
Name: {app}\apache-tomcat\webapps\ROOT\WEB-INF\lib\*; Type: filesandordirs; Check: Run_A; BeforeInstall: StopTomcat

[Files]
Source: apache-tomcat\*; DestDir: {app}\apache-tomcat; Check: Run_B; Flags: ignoreversion recursesubdirs createallsubdirs
Source: apache-tomcat\msvcr71.dll; DestDir: {sys}\; Check: Run_B; Flags: onlyifdoesntexist
Source: {#MyWebContentPath}\*; DestDir: {app}\apache-tomcat\webapps\ROOT; Check: Run_B; Flags: ignoreversion recursesubdirs createallsubdirs
Source: download\*; DestDir: {app}\apache-tomcat\webapps\ROOT\public\download\; Check: Run_B; Flags: ignoreversion recursesubdirs createallsubdirs
Source: configs\WEB-INF\settings.properties; DestDir: {app}\apache-tomcat\webapps\ROOT\WEB-INF\; Check: Run_B; Flags: ignoreversion; AfterInstall: ReplacePathInConfigs
Source: configs\WEB-INF\classes\log4j.xml; DestDir: {app}\apache-tomcat\webapps\ROOT\WEB-INF\classes\; Check: Run_B; Flags: ignoreversion; AfterInstall: ReplacePathInConfigs
Source: configs\nginx_to_autorun.reg; DestDir: {app}\nginx\; Check: Run_B; Flags: ignoreversion; AfterInstall: ReplacePathInConfigsReg
Source: nginx\add_reg.bat; DestDir: {app}\nginx\; Check: Run_B; Flags: ignoreversion; AfterInstall: ReplacePathInConfigsReg
Source: nginx\*; DestDir: {app}\nginx; Check: Run_B; Flags: ignoreversion recursesubdirs createallsubdirs
Source: dbinit\*; DestDir: {app}\dbinit; Check: Run_B; Flags: ignoreversion recursesubdirs; AfterInstall: ReplacePathInConfigsPass
Source: UserMenu\*; DestDir: {app}; Check: Run_B; Flags: ignoreversion recursesubdirs; Languages: ; AfterInstall: ReplacePathInConfigs
Source: {#MySetupDbPath}\db\*.sql; DestDir: {app}\dbinit; Check: Run_B; Flags: ignoreversion




Source: {app}\apache-tomcat\webapps\ROOT\*; DestDir: {app}\backups\Webcontent-before-{#MyAppVer}.{#MyAppPatch}-{code:GetTodaysName}; Check: Run_A; Flags: ignoreversion recursesubdirs createallsubdirs external uninsneveruninstall; Components: backup_app
Source: {#MyWebContentPath}\*; DestDir: {app}\apache-tomcat\webapps\ROOT; Check: Run_A; Flags: ignoreversion recursesubdirs createallsubdirs; BeforeInstall: StopTomcat
Source: download\*; DestDir: {app}\apache-tomcat\webapps\ROOT\public\download\; Check: Run_A; Flags: ignoreversion recursesubdirs createallsubdirs; BeforeInstall: AddDefaultToConfig
Source: apache-tomcat\bin\service.bat; DestDir: {app}\apache-tomcat\bin\; Check: Run_A; Flags: ignoreversion recursesubdirs createallsubdirs; BeforeInstall: AddDefaultToConfig
Source: configs\WEB-INF\settings.properties; Check: Run_A; Flags: dontcopy
;Source: configs\WEB-INF\classes\log4j.xml; DestDir: {app}\apache-tomcat\webapps\ROOT\WEB-INF\classes\; Flags: ignoreversion; AfterInstall: ReplacePathInConfigs
Source: db_update\*; DestDir: {app}\db_update; Check: Run_A; Flags: ignoreversion recursesubdirs createallsubdirs; Languages: 
;Source: D:\work\_Stable\setup\db\update\{#MyAppVer}\*.sql; DestDir: {app}\db_update\sql_scripts; Flags: ignoreversion
Source: {#MySetupDbPath}\db\*.sql; DestDir: {app}\db_update\sql_scripts; Check: Run_A; Flags: ignoreversion recursesubdirs createallsubdirs

Source: dontcopy\netstat1.bat; Flags: dontcopy
Source: dontcopy\check.bat; Check: Run_A; Flags: dontcopy
Source: dontcopy\check.bat; Check: Run_B; Flags: dontcopy

[Icons]
Name: {group}\{#MyAppName}; Check: Run_B; Filename: {#InstalledLocalURL}
;Name: {group}\Start Tomcat; Filename: {app}\TomcatServiceStart.exe; WorkingDir: {app}\; Comment: {cm:RunTomcat}; Flags: runminimized; Components:
;Name: {group}\Stop Tomcat; Filename: {app}\TomcatServiceStop.exe; WorkingDir: {app}\; Comment: {cm:StopTomcat}; Flags: runminimized
Name: {group}\{cm:AdminManual}; Filename: {app}\apache-tomcat\webapps\ROOT\public\download\User_Manual\Manual_PDF\admin_manual.pdf; Check: Run_B; Languages: ru
Name: {group}\{cm:UserManual}; Filename: {app}\apache-tomcat\webapps\ROOT\public\download\User_Manual\Manual_PDF\user_manual.pdf; Check: Run_B; Languages: ru
Name: {group}\{cm:AdminManual}; Filename: {app}\apache-tomcat\webapps\ROOT\public\download\User_Manual\ua\manual_admin.pdf; Check: Run_B; Languages: ua
Name: {group}\{cm:UserManual}; Filename: {app}\apache-tomcat\webapps\ROOT\public\download\User_Manual\ua\manual_user.pdf; Check: Run_B; Languages: ua
Name: {group}\{cm:Rukovodstvo_administratora}; Check: Run_B; Filename: {app}\apache-tomcat\webapps\ROOT\public\download\User_Manual\Manual_PDF\Rukovodstvo_administratora.pdf
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Check: Run_B; Filename: {uninstallexe}






[Run]
Filename: {app}\apache-tomcat\bin\service.bat; Parameters: " install"; WorkingDir: {app}\apache-tomcat\bin\; Flags: runhidden; Check: Run_B; StatusMsg: Installing Apache Tomcat as Service
Filename: NET; Parameters: "START ""Apache Tomcat"""; Flags: runhidden; Components: PostgreSQL; Check: Run_B; StatusMsg: {cm:StartingTomcat}
Filename: {app}\dbinit\createAndInitDb.bat; Parameters: """{code:GetPsqlPath}""  {language}"; WorkingDir: {app}\dbinit\; Flags: shellexec runhidden waituntilterminated; Check: Run_B; Components: PostgreSQL; StatusMsg: {cm:CreatingDatabase}
Filename: {app}\nginx\add_reg.bat; Check: Run_B; Flags: shellexec runhidden
Filename: {app}\start_nginx.bat; Check: Run_B; Flags: shellexec runhidden
Filename: {app}\dbinit\installAdditionalCards.bat; Parameters: """{code:GetPsqlPath}"" {language}"; WorkingDir: {app}\dbinit\; Check: Run_B; Flags: shellexec runhidden waituntilterminated; Components: PostgreSQL; StatusMsg: {cm:CreatingDatabase}; Tasks: IntstallDefaultShemes
Filename: {app}\Synergy Center.url; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent shellexec; Check: Run_B; Components: PostgreSQL


;Filename: {app}\postgresql\bin\pg_dump.exe; Parameters: "-h localhost -p 5432 -U postgres -F c -b -v -f ""{app}\backups\db-before-{#MyAppVer}.{#MyAppPatch}-{code:GetTodaysName}.backup"" sc"; Flags: waituntilterminated; StatusMsg: ????? ??????? ??; Components: backup_db
Filename: {app}\apache-tomcat\bin\service.bat; Parameters: " remove"; WorkingDir: {app}\apache-tomcat\bin\; Check: Run_A; Flags: runhidden
Filename: {app}\apache-tomcat\bin\service.bat; Parameters: " install"; WorkingDir: {app}\apache-tomcat\bin\; Check: Run_A; Flags: runhidden
Filename: {app}\db_update\make_db_backup.bat; WorkingDir: {app}\; Flags: shellexec  waituntilterminated; StatusMsg: StatusMsg: {cm:BackupingCurrentDB}; Check: Run_A; Components: backup_db
;Filename: NET; Parameters: "STOP ""Apache Tomcat"""; Flags: runhidden; StatusMsg: {cm:StoppingTomcat}
Filename: {app}\db_update\run_db_update.bat; WorkingDir: {app}\db_update\; Flags: shellexec  waituntilterminated; Check: Run_A; StatusMsg: {cm:UpdatingDatabase}
;Filename: java; Parameters: " -jar --patches_path=""./sql_scripts/"" --log=""./sql_scripts/sql_scripts_log.log"" --sc_properites_path=""{app}/apache-tomcat/webapps/ROOT/WEB-INF/settings.properties"" "; WorkingDir: {app}\db_update\; Flags: shellexec  waituntilterminated; StatusMsg: {cm:UpdatingDatabase}
;Filename: rmdir; Parameters: "/S /Q ""{app}\apache-tomcat\work\Catalina\"""; Flags: shellexec runhidden; StatusMsg: {cm:StartingTomcat}
Filename: NET; Parameters: "START ""Apache Tomcat"""; Flags: runhidden; Check: Run_A; StatusMsg: {cm:StartingTomcat}





[Components]
Name: Tomcat; Description: {cm:ApacheTomcatComponent}; Flags: fixed; Types: custom compact full; Check: Skips
Name: PostgreSQL; Description: {cm:PostgresComponent}; Types: custom full; Flags: checkablealone; ExtraDiskSpaceRequired: 16080384; Check: Skips; Languages: 

Name: backup_db; Description: {cm:MakeDBBackupComponent}; Flags: checkablealone; Types: custom full; Languages: ; ExtraDiskSpaceRequired: 5000000; Check: Skip
Name: backup_app; Description: {cm:MakeApplicationBackupComponent}; Flags: checkablealone; Types: custom full; ExtraDiskSpaceRequired: 50000000; Check: Skip

[Tasks]
Name: IntstallDefaultShemes; Description: {cm:IntstallDefaultShemes}; Flags: checkablealone; Components: Postgresql; Languages: 


[ Code]

var
  CheckBoxA: TNewCheckBox;
  CheckBoxB: TNewCheckBox;

  PasswordPage: TInputQueryWizardPage;
  DataDirPage: TInputDirWizardPage;

  UserVarPass: String;
  PathToPsql: String;
  CheckLicense: TNewCheckBox;



procedure ReplacePathInConfigsReg();
var filecontent: String;
var pathForConfig: String;
var langForConfig: String;
begin
  LoadStringFromFile(ExpandConstant(CurrentFileName), filecontent);
  langForConfig:=ExpandConstant('{language}');
  pathForConfig:=ExpandConstant('{app}');
  StringChange(pathForConfig,'\','\\');
  StringChange(filecontent,'{INSTALL_PATH}',pathForConfig);
  StringChange(filecontent,'{LANGUAGE}',langForConfig);
  SaveStringToFile(ExpandConstant(CurrentFileName), filecontent, false);
end;

function CheckPortUsing(Port: String; fileStrings: TArrayOfString): Boolean;
var i: Integer;
begin
   for i:=0 to GetArrayLength(fileStrings)-1 do
   begin
		if ((Pos(':'+Port+' ',fileStrings[i])>0) and (Pos('LISTENING',fileStrings[i]) >0)) then
			begin
				Result := true;
				exit;
			end;
  end;
  Result := false;
end;



procedure LicenseOnClick(Sender: TObject);
begin
  WizardForm.NextButton.Enabled := false;
  if (CheckLicense.Checked) = True then

  begin
    WizardForm.LicenseAcceptedRadio.Checked := True;
    WizardForm.NextButton.Enabled := True;
  end else
  begin
    WizardForm.LicenseNotAcceptedRadio.Checked := True;
    WizardForm.NextButton.Enabled := False;
  end;
end;


function  ShouldSkipPage(PageID: Integer): Boolean;
begin
  case PageID of
    wpLicense: Result := True;
  end;
end;




function GetBuildNumber(param: String): String;
     var
          BuildVersion: String;
     begin
          LoadStringFromFile(ExpandConstant('buildNumber.txt'), BuildVersion);
          Result := BuildVersion;
     end;




function GetPsqlPath(Param: String): String;
begin
	Result := PathToPsql + '\psql.exe';
end;

procedure ReplacePathInConfigs();
var filecontent: String;
var pathForConfig: String;
var langForConfig: String;
begin
  LoadStringFromFile(ExpandConstant(CurrentFileName), filecontent);
  langForConfig:=ExpandConstant('{language}');
  pathForConfig:=ExpandConstant('{app}');
  StringChange(pathForConfig,'\','/');
  StringChange(filecontent,'{INSTALL_PATH}',pathForConfig);
  StringChange(filecontent,'{LANGUAGE}',langForConfig);
  SaveStringToFile(ExpandConstant(CurrentFileName), filecontent, false);
end;



procedure ReplacePathInConfigsPass();
var filecontent: String;
begin
  LoadStringFromFile(ExpandConstant(CurrentFileName), filecontent);
  StringChange(filecontent,'{PG_PASS}',UserVarPass);
  SaveStringToFile(ExpandConstant(CurrentFileName), filecontent, false);
end;




procedure StopTomcat();
var
  ErrorCode: Integer;
begin
  if not Exec('NET',' STOP "Apache Tomcat"', '' ,SW_HIDE, ewWaitUntilTerminated, ErrorCode) then
  begin
    MsgBox('Fail to stop tomcat', mbInformation, mb_Ok);
  end;
end;





function CheckDBUpdateIsOk(): Boolean;
var filecontent: String;
var pathToLog: String;
begin
  Result:= false;
  pathToLog:=ExpandConstant('{app}')+'\db_update\db_update_log.log';
  LoadStringFromFile(pathToLog, filecontent);
  if (Pos('Update succesfully',filecontent)>0) then
  begin
	Result:= true;
  end

end;


procedure CurPageChanged(CurPageID: Integer);
  var ResultCode: Integer;
Begin
	if CurPageID=wpWelcome then
    begin
      WizardForm.NextButton.Enabled := False;
    end;
end;





procedure AddDefaultToConfig();
var filecontent_default: String;
var configStrings,defaultStrings: TArrayOfString;
var pathToConfig,pathToDefaultConfig,appPath: String;
var langForConfig,currentKey: String;
var currentPos,i,j: Integer;
var containKey: Boolean;
begin

  ExtractTemporaryFile('settings.properties');
  pathToConfig:=ExpandConstant('{app}')+'\apache-tomcat\webapps\ROOT\WEB-INF\settings.properties';
  pathToDefaultConfig:=ExpandConstant('{tmp}\settings.properties');
  appPath:=ExpandConstant('{app}');
  langForConfig:=ExpandConstant('{language}');

  LoadStringFromFile(pathToDefaultConfig, filecontent_default);
  StringChange(appPath,'\','/');
  StringChange(filecontent_default,'{INSTALL_PATH}',appPath);
  StringChange(filecontent_default,'{LANGUAGE}',langForConfig);
  SaveStringToFile(pathToDefaultConfig, filecontent_default, false);

  LoadStringsFromFile(pathToDefaultConfig, defaultStrings);

  LoadStringsFromFile(pathToConfig, configStrings);

  for i:=0 to GetArrayLength(defaultStrings)-1 do
   begin
		currentPos:=Pos('=',defaultStrings[i]);
		if ((currentPos>0)) then
			begin
				currentKey:=Trim(Copy(defaultStrings[i], 0, currentPos-1));
				containKey:=false;
				  for j:=0 to GetArrayLength(configStrings)-1 do
					begin
						if ((Pos(currentKey,configStrings[j])>0)) then
						begin
							containKey:=true;
						end;
					end;
				if (containKey=false) then
					begin

						SetArrayLength(configStrings, GetArrayLength(configStrings)+1);
						configStrings[GetArrayLength(configStrings)-1]:=defaultStrings[i];
					end
			end;
  end;
  SaveStringsToFile(pathToConfig, configStrings, false);
end;


var
  TodaysName : String;

function GetToday : String;
begin
  Result := GetDateTimeString ('yyyy.mm.dd hh.nn.ss', '-', #0);
end;

function GetTodaysName (Param: String): String;
begin
  if ('' = TodaysName) then
  begin
    TodaysName := GetToday ();
  end;
  Result := TodaysName;
end;







function Run_A: Boolean; begin Result:=CheckBoxA.Checked; end;
function Run_B: Boolean; begin Result:=CheckBoxB.Checked; end;


Function InitializeSetup: Boolean;
  var ResultCode: Integer;
  var fileStrings: TArrayOfString;
  var pathToOutput: String;
  var outputFile: String;


Begin

	If (ExpandConstant('{reg:HKLM\Software\JavaSoft\Java Runtime Environment,CurrentVersion}') = '1.6') then
		Result:= True
	else MsgBox(ExpandConstant('{cm:SetupJRE}'), mbInformation, mb_Ok);


	outputFile:=ExpandConstant('{tmp}\netstatoutput.log');
	pathToOutput:=ExpandConstant('{tmp}\');
	ExtractTemporaryFile('netstat1.bat');
	if Exec(ExpandConstant('{tmp}\netstat1.bat'),  'netstatoutput.log', pathToOutput, SW_HIDE, ewWaitUntilTerminated, ResultCode) then
	begin
		//MsgBox(outputFile, mbInformation, mb_Ok);
		// handle success if necessary; ResultCode contains the exit code
		LoadStringsFromFile(outputFile, fileStrings);
		DeleteFile(outputFile);
		DeleteFile(ExpandConstant('{tmp}\netstat1.bat'));
		If (CheckPortUsing('80',fileStrings) and (Result=true)) then
		begin
		  Result := MsgBox(ExpandConstant('{cm:Port80InUse}'), mbConfirmation, MB_YESNO) = idYes;
		end
  end
  else MsgBox('Error ', mbInformation, mb_Ok);
End;

var
ReturnCode: Integer;
procedure InitializeWizard;
begin
  WizardForm.WelcomeLabel1.Hide;
  WizardForm.WelcomeLabel2.Hide;
  WizardForm.LicenseNotAcceptedRadio.Hide;
  WizardForm.LicenseAcceptedRadio.Hide;
  { CheckLicense }
  CheckLicense := TNewCheckBox.Create(WizardForm);
  with CheckLicense do
  begin
    Name := 'CheckLicense';
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(176);
    Top := ScaleY(288);
    Width := ScaleX(200);
    Height := ScaleY(17);
    OnClick := @LicenseOnClick;
    CheckLicense.Caption := WizardForm.LicenseAcceptedRadio.Caption;
  end;

  with WizardForm.LicenseMemo do
  begin
    Left := ScaleX(164);
    Top := ScaleY(0);
    Width := ScaleX(333);
    Height := ScaleY(284);
    Parent := WizardForm.WelcomePage;
  end;
        CheckLicense.Checked := false;

  DataDirPage := CreateInputDirPage(wpSelectDir, ExpandConstant('{cm:DirSelectCaption}'), ExpandConstant('{cm:DirSelectDescription}'), ExpandConstant('{cm:DirSelectSubCaption}'), False, '' );
  DataDirPage.Add('');
  DataDirPage.Values[0] := GetPreviousData('DataDir', 'C:\Program Files\PostgreSQL\9.0\bin');

  PasswordPage := CreateInputQueryPage(DataDirPage.ID, ExpandConstant('{cm:PasswordInputCaption}') ,ExpandConstant('{cm:PasswordInputDescription}'), ExpandConstant('{cm:PasswordInputSubCapton}') );
  PasswordPage.Add(SetupMessage(msgPasswordEditLabel), True);


  { CheckBoxA }
  CheckBoxA := TNewCheckBox.Create(WizardForm);
  with CheckBoxA do
  begin
    Name := 'CheckBoxA';
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(216);
    Top := ScaleY(176);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'вариант 1';
  end;
  { CheckBoxB }
  CheckBoxB := TNewCheckBox.Create(WizardForm);
  with CheckBoxB do
  begin
    Name := 'CheckBoxB';
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(216);
    Top := ScaleY(208);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'Вариант 2';
  end;

  if RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Corssys\Synergy Center') or
     RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\IVTBelGU\Synergy Center')
   then
    begin

      CheckBoxA.Enabled:=true;
      CheckBoxA.Checked:=true;

      CheckBoxB.Enabled:=false;
      CheckBoxB.Checked:=false;
    end

  else
    begin
      CheckBoxA.Enabled:=false;
      CheckBoxA.Checked:=false;

      CheckBoxB.Enabled:=true;
      CheckBoxB.Checked:=true;
    end;
CheckBoxA.visible:=false;
CheckBoxB.visible:=false;


end;


function NextButtonClick(CurPageID: Integer): Boolean;
var filecontent: String;
	ReturnCode: Integer;


begin
  Result := True;
  if CurPageID = DataDirPage.ID then begin
	if FileExists ( DataDirPage.Edits[0].Text + '\psql.exe' ) then
		begin
			Result := True;
			PathToPsql := DataDirPage.Edits[0].Text;
		end
	else
		begin
			MsgBox(ExpandConstant('{cm:msgNotFoundPsql}'), mbError, MB_OK);
			Result := False;
		end;
	end;


begin
if CheckBoxA.Checked = true then
begin


begin
  Result := True;
 If CurPageID = wpSelectDir then
  begin
	If (FileSearch('settings.properties', ExpandConstant('{app}')+'\apache-tomcat\webapps\ROOT\WEB-INF')='') then
	begin
		MsgBox(ExpandConstant('{cm:ErrorSCNotFound}'), mbCriticalError, mb_Ok);
		Result:=False;
	end
 end;


  if CurPageID = PasswordPage.ID then begin
	UserVarPass := PasswordPage.Edits[0].Text;
	ExtractTemporaryFile('check.bat');
    Exec (ExpandConstant ( '{tmp}\check.bat' ), PasswordPage.Edits[0].Text + ' "' + PathToPsql + '"' , ExpandConstant ( '{tmp}' ), SW_HIDE, ewWaitUntilTerminated, ReturnCode );
	if ReturnCode = 0 then
		begin
			Result := True;
		end
	else
		begin
			MsgBox(ExpandConstant('{cm:msgIncorrectPassword}'), mbError, MB_OK);
			Result := False;
		end;
	DeleteFile ( ExpandConstant ('{tmp}\check.bat') );
  end;
end;


end;


if CheckBoxB.Checked = true then
  begin


  if CurPageID = PasswordPage.ID then begin
	UserVarPass := PasswordPage.Edits[0].Text;
	ExtractTemporaryFile('check.bat');
    Exec (ExpandConstant ( '{tmp}\check.bat' ), PasswordPage.Edits[0].Text + ' "' + PathToPsql + '"' , ExpandConstant ( '{tmp}' ), SW_HIDE, ewWaitUntilTerminated, ReturnCode );
	if ReturnCode = 0 then
		begin
			Result := True;
		end
	else
		begin
			MsgBox(ExpandConstant('{cm:msgIncorrectPassword}'), mbError, MB_OK);
			Result := False;
		end;
	DeleteFile ( ExpandConstant ('{tmp}\check.bat') );
  end;
end;

end;

end;

function Skip:boolean;
var
  sz:Integer;
  s:string;
begin
  Result:=True;
begin
 If not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Corssys\Synergy Center') or
     RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\IVTBelGU\Synergy Center') then
  Result:=False
end;
end;
function Skips:boolean;
var
  sz:Integer;
  s:string;
begin
  Result:=True;
begin
 If RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Corssys\Synergy Center') or
     RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\IVTBelGU\Synergy Center') then
  Result:=False
end;
end;
вот скрипт удаления
Код: Выделить весь код
#define MyAppName "Uninstall"

[Setup]
AppId=proto15
SourceDir=.
OutputDir=Setup
AppName={#MyAppName}
AppVerName={#MyAppName}
AppVersion={#MyAppName}
CreateAppDir=false
OutputBaseFilename={#MyAppName}
Uninstallable=false

ShowLanguageDialog=auto
LanguageDetectionMethod=uilanguage
UsePreviousLanguage=no
DisableProgramGroupPage=yes
DisableWelcomePage=yes
DisableDirPage=yes
DisableReadyPage=yes
DisableFinishedPage=yes



[Languages]
Name: ru; MessagesFile: i18n\Russian.isl,i18n\sc_russian.isl
Name: ua; MessagesFile: i18n\Ukrainian-6-5.1.11.isl,i18n\sc_ukrainian.isl

[InstallDelete]



[Files]
Source: {src}\files\*; DestDir: {code:SrcDir}\files\; Flags: ignoreversion recursesubdirs createallsubdirs external; Check: make_copy
Source: {src}\license\*; DestDir: {code:SrcDir}\license\; Flags: ignoreversion recursesubdirs createallsubdirs external; Check: make_copy
Source: dontcopy\check.bat; Flags: dontcopy
Source: dontcopy\checkdb.bat; Flags: dontcopy
[Run]
Filename: {src}\make_db_backup.bat; Parameters: {code:GetPsqlPass}; Flags: shellexec runhidden waituntilterminated; Check: make_copy
Filename: {src}\delbase.bat; Parameters: {code:GetPsqlPass}; Flags: shellexec runhidden waituntilterminated


Filename: NET; Parameters: "STOP ""Apache Tomcat"""; Flags: runhidden
Filename: {src}\apache-tomcat\bin\service.bat; Parameters: " remove"; WorkingDir: {src}\apache-tomcat\bin\; Flags: runhidden; Components: 
Filename: {src}\stop_nginx.bat; WorkingDir: {src}\; Components: 
[ Code]
{ RedesignWizardFormBegin } // Не удалять эту строку!
// Не изменять эту секцию. Она создана автоматически.
var
  ISCustomPage1: TWizardPage;
  SuperBackupCheckBox: TNewCheckBox;
  Edit_1: TNewEdit;
  WhereButton: TNewButton;
  DataDirPage: TInputDirWizardPage;
  PasswordPage: TInputQueryWizardPage;
  UserVarPass: String;

procedure RePlaceTextinFile(FilePath:string; find:string; replace:string);
var
  S: TArrayOfString;
  i : Integer;
begin
  if not FileExists(FilePath) then begin MsgBox('Файл не найден ' + FilePath, mbError, mb_Ok); Exit;end; // если файла нет, выходим
  LoadStringsFromFile(FilePath, S); // загружаем файл
  for i:= 0 to GetArrayLength(S)-1 do begin
    if (Pos(AnsiUpperCase(find), AnsiUpperCase(S[i])) > 0) then begin
      StringChangeEx(S[i], find, replace, True);
    end;
  end;
  SaveStringsToFile(FilePath, S, False); // сохраняем файл
end;

procedure make_copy_again(Sender: TObject); forward;
procedure ButtonOnClick(Sender: TObject); forward;


procedure RedesignWizardForm;
begin
  { Creates custom wizard page }
  ISCustomPage1 := CreateCustomPage(wpSelectDir, 'BackUpPage', 'ISCustomPage1_Description');

  { ISCustomPage1 }
  with ISCustomPage1.Surface do
  begin
    Name := 'ISCustomPage1';
  end;

  { SuperBackupCheckBox }
  SuperBackupCheckBox := TNewCheckBox.Create(WizardForm);
  with SuperBackupCheckBox do
  begin
    Name := 'SuperBackupCheckBox';
    Parent := ISCustomPage1.Surface;
    Left := ScaleX(16);
    Top := ScaleY(24);
    Width := ScaleX(169);
    Height := ScaleY(17);
    Hint := 'бэкап нужен?';
    Caption := 'Мне бы резервную копию';

    ShowHint := True;
    OnClick := @make_copy_again;
  end;

  { Edit_1 }
  Edit_1 := TNewEdit.Create(WizardForm);
  with Edit_1 do
  begin
    Name := 'Edit_1';
    Parent := ISCustomPage1.Surface;
    Left := ScaleX(16);
    Top := ScaleY(56);
    Width := ScaleX(393);
    Height := ScaleY(21);
    Text := 'C:\';
  end;

  { WhereButton }
  WhereButton := TNewButton.Create(WizardForm);
  with WhereButton do
  begin
    Name := 'WhereButton';
    Parent := ISCustomPage1.Surface;
    Left := ScaleX(168);
    Top := ScaleY(80);
    Width := ScaleX(75);
    Height := ScaleY(25);
    Caption := 'куда?';
    OnClick := @ButtonOnClick;
  end;

  SuperBackupCheckBox.TabOrder := 0;
  Edit_1.TabOrder := 1;
  WhereButton.TabOrder := 2;

{ ReservationBegin }
  // Вы можете добавить ваш код здесь.

{ ReservationEnd }
end;
// Не изменять эту секцию. Она создана автоматически.
{ RedesignWizardFormEnd } // Не удалять эту строку!

function make_copy: Boolean;
begin
    Result:=SuperBackupCheckBox.Checked;
end;





procedure make_copy_again (Sender: TObject);
begin
if SuperBackupCheckBox.Checked = false then
  begin
    Edit_1.Enabled:= false;
    Edit_1.visible:= false;
    WhereButton.Enabled:= false;
    WhereButton.visible:= false;
  end
else
  begin
    Edit_1.Enabled:= true;
    Edit_1.visible:= true;
    WhereButton.Enabled:= true;
    WhereButton.visible:= true;


  end;
end;

var
  DataDir: String;

function SrcDir(Param: String): String;
begin
  Result := DataDir;
end;

procedure ButtonOnClick(Sender: TObject);
var
  res: Boolean;
begin
  DataDir := ExpandConstant('{src}');
  res := BrowseForFolder('Выберите папку из списка и нажмите «ОК»', DataDir, True);
  if res then
    begin
      Edit_1.Text := DataDir;
    end;
    RePlaceTextinFile(ExpandConstant('{src}\make_db_backup.bat'), '%~dp0\backups', DataDir);
end;
function PUTT(filepath:string):string;
var
S: TArrayOfString;
i : Integer;
begin
if not FileExists(FilePath) then begin MsgBox('Файл не найден ' + FilePath, mbError, mb_Ok); Exit;end; // если файла нет, выходим
LoadStringsFromFile(FilePath, S); // загружаем файл
result := S[0];
end;
procedure InitializeWizard();
begin
  RedesignWizardForm;
  Edit_1.Text := ExpandConstant('{userdocs}');
  Edit_1.Enabled:= false;
  Edit_1.visible:= false;
  WhereButton.Enabled:= false;
  WhereButton.visible:= false;
  DataDirPage := CreateInputDirPage(wpSelectDir, ExpandConstant('Добро пожаловать'), ExpandConstant('в процесс Удаление SC'), ExpandConstant('Следуюте инструкции. нажмите далее чтоб продолжить удаление или отмена чтоб ее отменить'), False, '' );
  PasswordPage := CreateInputQueryPage(DataDirPage.ID, ExpandConstant('Пароль') ,ExpandConstant('к баззе данных'), ExpandConstant('Введите') );
  PasswordPage.Add(SetupMessage(msgPasswordEditLabel), True);
 end;

function NextButtonClick(CurPageID: Integer): Boolean;
var filecontent: String;
  ReturnCode: Integer;

begin
  Result := True;


  if CurPageID = PasswordPage.ID then begin
  UserVarPass := PasswordPage.Edits[0].Text;
  ExtractTemporaryFile('check.bat');
  Exec (ExpandConstant ('{tmp}\check.bat'), PasswordPage.Edits[0].Text + ' "' + PUTT(ExpandConstant('{src}\text.txt')) + '"', ExpandConstant ( '{tmp}' ), SW_HIDE, ewWaitUntilTerminated, ReturnCode );
  if ReturnCode = 0 then
    begin
      Result := True;
    end
  else
    begin
      MsgBox(ExpandConstant('Не верный пароль'), mbError, MB_OK);
      Result := False;
    end;
  DeleteFile ( ExpandConstant ('{tmp}\check.bat') );
  end;

end;
function GetPsqlPass(Param: String): String;
begin
  Result := UserVarPass;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  Confirm := False;
end;

Отправлено: 17:33, 25-04-2012 | #1668