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

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

Аватара для ErikPshat

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


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

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


Цитата Romann_:
Но как можно ещё проверить разрядность системы?(У некоторых всё ещё есть win7 х86.) »
Ну могу поделиться готовым рабочим шаблоном по определению версии Windows (XP/7/Vista/8/8.1/10) и её разрядности. Там как раз ответы на все ваши вопросы, надеюсь разберётесь. Правда там подмешано определение, скачивание и установка нужной версии PowerShell. Ну и ещё там подключён плагин "Inno Download Plugin", подключён скин и подключена заставка, ну и ещё 3 языка. Надеюсь вы сами сможете убрать что лишнее и применить по своему назначению... Правда там это всё реализовано совсем по-другому, у меня прекрасно работает, может пригодится и поможет. Название программы и ссылки изменены. Не забудьте убрать нижнее подчёркивание из названия секции [_Code]
Скрипт полный
Код: Выделить весь код
;InnoSetupVersion=5.6.1 (Unicode)
#pragma include __INCLUDE__ + ";" + ReadReg(HKLM, "Software\Mitrich Software\Inno Download Plugin", "InstallDir")

#define MyApp "My Super-Puper Programm"
#define ShortName "MSPP"
#define Version "3.4.2"
#define Publisher "by SuperUser"
#define Team "Super Team"
#define URL "http://forum.oszone.net/post-2881225.html"
#define UpdatesURL "https://github.com/SuperUser/SuperTeam/blob/master/update.exe"
#define ExeName "MSPP"
#define Skin "CrystalBlue"

[Setup]
AppId={{E4F0B51A-4567-4C49-AD5D-D9A8B6BBBCF3F}
AppName={#ShortName}
AppVersion={#Version}
AppVerName={#MyApp} v{#Version}
AppPublisher={#MyApp} {#Team}
AppPublisherURL={#URL}
AppSupportURL={#URL}
AppUpdatesURL={#UpdatesURL}
DefaultDirName={sd}\{#ShortName}
DefaultGroupName={#ShortName}
ShowLanguageDialog=no
UninstallDisplayIcon={app}\MSPP.exe
UninstallDisplayName={#ShortName}
AllowNoIcons=yes
OutputDir=.
OutputBaseFilename=setup
SetupIconFile=embedded\myicon.ico
WizardImageFile=embedded\WizardImage.bmp
WizardSmallImageFile=embedded\WizardSmallImage.bmp
WizardImageAlphaFormat=premultiplied 
VersionInfoCompany={#Team}
VersionInfoCopyright={#ShortName} {#Publisher}
VersionInfoDescription={#MyApp} {#Publisher} 
VersionInfoVersion={#Version}
Compression=lzma2/max
SolidCompression=Yes

#include <idp.iss>
#include <idplang\Russian.iss>
#include <idplang\German.iss>

[Files]
Source: "embedded\ISSkin\ISSkinU.dll"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\ISSkin\Styles\{#Skin}.cjstyles"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z.dll"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z.exe"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z32.dll"; DestDir: {tmp}; Flags: dontcopy
Source: "embedded\7z32.exe"; DestDir: {tmp}; Flags: dontcopy
Source: "{app}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "embedded\EN\config.ini"; DestDir: "{app}"; Languages: en; Flags: ignoreversion
Source: "embedded\RU\config.ini"; DestDir: "{app}"; Languages: ru; Flags: ignoreversion
Source: "embedded\DE\config.ini"; DestDir: "{app}"; Languages: de; Flags: ignoreversion

[Languages]
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"; InfoBeforeFile: "embedded\InfoBefore-ru.rtf"
Name: "en"; MessagesFile: "compiler:Default.isl"; InfoBeforeFile: "embedded\InfoBefore-en.rtf"
Name: "de"; MessagesFile: "compiler:Languages\German.isl"; InfoBeforeFile: "embedded\InfoBefore-de.rtf"

[CustomMessages]
ru.CautionXP64=Для работы программы требуется PowerShell 5.1.%nНа Windows XP 64bit программа не сможет скачивать обновления для конвертации игр и выполнять некоторые другие функции.
ru.CautionVI64=Для работы программы требуется PowerShell 5.1.%nНа Windows Vista 64bit программа не сможет скачивать обновления для конвертации игр и выполнять некоторые другие функции.
ru.Caution7064=На компьютере обнаружена устаревшая версия PowerShell.%nПосле установки программы будет произведено скачивание и установка обновления PowerShell 5.1 для Windows 7 64bit.%n%nПожалуйста, дождитесь завершения обновления!
ru.Caution8064=На компьютере обнаружена устаревшая версия PowerShell.%nПосле установки программы будет произведено скачивание и установка обновления PowerShell 5.1 для Windows 8.0 64bit.%n%nПожалуйста, дождитесь завершения обновления!
ru.Caution8164=На компьютере обнаружена устаревшая версия PowerShell.%nПосле установки программы будет произведено скачивание и установка обновления PowerShell 5.1 для Windows 8.1 64bit.%n%nПожалуйста, дождитесь завершения обновления!
ru.CautionXP32=Для работы программы требуется PowerShell 5.1.%nНа Windows XP 32bit программа не сможет скачивать обновления для конвертации игр и выполнять некоторые другие функции.
ru.CautionVI32=Для работы программы требуется PowerShell 5.1.%nНа Windows Vista 32bit программа не сможет скачивать обновления для конвертации игр и выполнять некоторые другие функции.
ru.Caution7032=На компьютере обнаружена устаревшая версия PowerShell.%nПосле установки программы будет произведено скачивание и установка обновления PowerShell 5.1 для Windows 7 32bit.%n%nПожалуйста, дождитесь завершения обновления!
ru.Caution8132=На компьютере обнаружена устаревшая версия PowerShell.%nПосле установки программы будет произведено скачивание и установка обновления PowerShell 5.1 для Windows 8.1 32bit.%n%nПожалуйста, дождитесь завершения обновления!

en.CautionXP64=The program requires PowerShell 5.1.%nOn Windows XP 64bit, the program will not be able to download updates for converting games and perform some other functions.
en.CautionVI64=The program requires PowerShell 5.1.%nOn Windows Vista 64bit, the program will not be able to download updates for converting games and perform some other functions.
en.Caution7064=An outdated version of PowerShell has been detected on your computer.%nAfter installing the program, the PowerShell 5.1 update for Windows 7 64bit will be downloaded and installed.%n%nPlease wait until the update is complete!
en.Caution8064=An outdated version of PowerShell has been detected on your computer.%nAfter installing the program, the PowerShell 5.1 update for Windows 8.0 64bit will be downloaded and installed.%n%nPlease wait until the update is complete!
en.Caution8164=An outdated version of PowerShell has been detected on your computer.%nAfter installing the program, the PowerShell 5.1 update for Windows 8.1 64bit will be downloaded and installed.%n%nPlease wait until the update is complete!
en.CautionXP32=The program requires PowerShell 5.1.%nOn Windows XP 32bit, the program will not be able to download updates for converting games and perform some other functions.
en.CautionVI32=The program requires PowerShell 5.1.%nOn Windows Vista 32bit, the program will not be able to download updates for converting games and perform some other functions.
en.Caution7032=An outdated version of PowerShell has been detected on your computer.%nAfter installing the program, the PowerShell 5.1 update for Windows 7 32bit will be downloaded and installed.%n%nPlease wait until the update is complete!
en.Caution8132=An outdated version of PowerShell has been detected on your computer.%nAfter installing the program, the PowerShell 5.1 update for Windows 8.1 32bit will be downloaded and installed.%n%nPlease wait until the update is complete!

de.CautionXP64=Das Programm erfordert PowerShell 5.1.%nUnter Windows XP 64bit kann das Programm keine Updates zum Konvertieren von Spielen herunterladen und einige andere Funktionen ausführen.
de.CautionVI64=Das Programm erfordert PowerShell 5.1.%nUnter Windows Vista 64bit kann das Programm keine Updates zum Konvertieren von Spielen herunterladen und einige andere Funktionen ausführen.
de.Caution7064=Auf Ihrem Computer wurde eine veraltete Version von PowerShell erkannt.%nNach der Installation des Programms wird das PowerShell 5.1-Update für Windows 7 64bit heruntergeladen und installiert.%n%nBitte warten Sie bis das Update abgeschlossen ist!
de.Caution8064=Auf Ihrem Computer wurde eine veraltete Version von PowerShell erkannt.%nNach der Installation des Programms wird das PowerShell 5.1-Update für Windows 8.0 64bit heruntergeladen und installiert.%n%nBitte warten Sie bis das Update abgeschlossen ist!
de.Caution8164=Auf Ihrem Computer wurde eine veraltete Version von PowerShell erkannt.%nNach der Installation des Programms wird das PowerShell 5.1-Update für Windows 8.1 64bit heruntergeladen und installiert.%n%nBitte warten Sie bis das Update abgeschlossen ist!
de.CautionXP32=Das Programm erfordert PowerShell 5.1.%nUnter Windows XP 32bit kann das Programm keine Updates zum Konvertieren von Spielen herunterladen und einige andere Funktionen ausführen.
de.CautionVI32=Das Programm erfordert PowerShell 5.1.%nUnter Windows Vista 32bit kann das Programm keine Updates zum Konvertieren von Spielen herunterladen und einige andere Funktionen ausführen.
de.Caution7032=Auf Ihrem Computer wurde eine veraltete Version von PowerShell erkannt.%nNach der Installation des Programms wird das PowerShell 5.1-Update für Windows 7 32bit heruntergeladen und installiert.%n%nBitte warten Sie bis das Update abgeschlossen ist!
de.Caution8132=Auf Ihrem Computer wurde eine veraltete Version von PowerShell erkannt.%nNach der Installation des Programms wird das PowerShell 5.1-Update für Windows 8.1 32bit heruntergeladen und installiert.%n%nBitte warten Sie bis das Update abgeschlossen ist!

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"

[Icons]
Name: "{group}\{#ShortName}"; Filename: "{app}\{#ExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#ShortName}}"; Filename: "{#URL}"
Name: "{group}\{cm:UninstallProgram,{#ShortName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#ShortName}"; Filename: "{app}\{#ExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#ShortName}"; Filename: "{app}\{#ExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#ExeName}"; Description: "{cm:LaunchProgram,{#StringChange(ShortName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[_Code]
procedure LoadSkin(lpszPath: String; lpszIniFileName: String); external 'LoadSkin@files:ISSkinU.dll stdcall';
procedure UnloadSkin(); external 'UnloadSkin@files:ISSkinU.dll stdcall';
function ShowWindow(hWnd: Integer; uType: Integer): Integer; external 'ShowWindow@user32.dll stdcall';

function IsWindowsVersionOrNewer(Major, Minor: Integer): Boolean;
var
  Version: TWindowsVersion;
begin
  GetWindowsVersionEx(Version);
  Result := (Version.Major > Major) or ((Version.Major = Major) and (Version.Minor >= Minor));
end;

function IsWindowsXPOrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(5, 1); end;
function IsWindowsViOrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(6, 0); end;
function IsWindows70OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(6, 1); end;
function IsWindows80OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(6, 2); end;
function IsWindows81OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(6, 3); end;
function IsWindows10OrNewer: Boolean; begin Result := IsWindowsVersionOrNewer(10,0); end;

function InitializeSetup(): Boolean;
begin
  ExtractTemporaryFile('{#Skin}.cjstyles');
  LoadSkin(ExpandConstant('{tmp}\{#Skin}.cjstyles'), '');
	Result := True;
end;

// Скачиваем PowerShell 5.1 под нашу версию Windows и битность...
procedure InitializeWizard;
var
  PSVersion: String;
begin
  RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine','PowerShellVersion', PSVersion);
  if Copy(PSVersion,1,3) < '5.1' then
   begin
    if IsWin64 then
     begin
      if IsWindowsXPOrNewer and not IsWindowsViOrNewer then begin MsgBox(ExpandConstant('{cm:CautionXP64}'),mbCriticalError, MB_OK); end else
      if IsWindowsViOrNewer and not IsWindows70OrNewer then begin MsgBox(ExpandConstant('{cm:CautionVI64}'),mbCriticalError, MB_OK); end else
      if IsWindows70OrNewer and not IsWindows80OrNewer then begin MsgBox(ExpandConstant('{cm:Caution7064}'), mbInformation, MB_OK);
        idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip',ExpandConstant('{tmp}\Win7AndW2K8R2-KB3191566-x64.zip'),68076477); end else
      if IsWindows80OrNewer and not IsWindows81OrNewer then begin MsgBox(ExpandConstant('{cm:Caution8064}'), mbInformation, MB_OK);
        idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/W2K12-KB3191565-x64.msu',ExpandConstant('{tmp}\W2K12-KB3191565-x64.msu'),21585220); end else
      if IsWindows81OrNewer and not IsWindows10OrNewer then begin MsgBox(ExpandConstant('{cm:Caution8164}'), mbInformation, MB_OK);
        idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1AndW2K12R2-KB3191564-x64.msu',ExpandConstant('{tmp}\Win8.1AndW2K12R2-KB3191564-x64.msu'),19878906); end;
     end
    else
     begin
      if IsWindowsXPOrNewer and not IsWindowsViOrNewer then begin MsgBox(ExpandConstant('{cm:CautionXP32}'),mbCriticalError, MB_OK); end else
      if IsWindowsViOrNewer and not IsWindows70OrNewer then begin MsgBox(ExpandConstant('{cm:CautionVI32}'),mbCriticalError, MB_OK); end else
      if IsWindows70OrNewer and not IsWindows80OrNewer then begin MsgBox(ExpandConstant('{cm:Caution7032}'), mbInformation, MB_OK);
        idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7-KB3191566-x86.zip',ExpandConstant('{tmp}\Win7-KB3191566-x86.zip'),44821734); end else
      if IsWindows81OrNewer and not IsWindows10OrNewer then begin MsgBox(ExpandConstant('{cm:Caution8132}'), mbInformation, MB_OK);
        idpAddFileSize('https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win8.1-KB3191564-x86.msu',ExpandConstant('{tmp}\Win8.1-KB3191564-x86.msu'),15231117); end;
     end;
    idpDownloadAfter(wpReady);
   end;
end;

// Во время показа страницы загрузки открываем по умолчанию скрытые детали загрузки... 
procedure CurPageChanged(CurPageID: Integer); 
begin 
 if Assigned(IDPForm.Page) then
  begin
   if CurPageID = IDPForm.Page.ID then 
    begin 
     // Показать детали загрузки 
     idpShowDetails(True); 
     // Скрываем кнопку Подробно/Скрыть 
     IDPForm.DetailsButton.Visible := False; 
    end;
  end; 
end;

// Распаковываем ранее скачанный ZIP/MSU и запускаем установку... 
procedure CurStepChanged(CurStep: TSetupStep);
var
  ResultCode: Integer;
begin
  if CurStep = ssPostInstall then 
   begin
    if IsWin64 then
     begin
      if FileExists(ExpandConstant('{tmp}\Win7AndW2K8R2-KB3191566-x64.zip')) then
       begin
        ExtractTemporaryFile('7z.exe');
        ExtractTemporaryFile('7z.dll');
        ShellExec('open',ExpandConstant('{tmp}\7z.exe'),ExpandConstant('x -y -oExtractedArchive ')+ExpandConstant('Win7AndW2K8R2-KB3191566-x64.zip'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode);
        ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\ExtractedArchive\Win7AndW2K8R2-KB3191566-x64.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
       end;
      if FileExists(ExpandConstant('{tmp}\W2K12-KB3191565-x64.msu')) then ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\W2K12-KB3191565-x64.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
      if FileExists(ExpandConstant('{tmp}\Win8.1AndW2K12R2-KB3191564-x64.msu')) then ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\Win8.1AndW2K12R2-KB3191564-x64.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
     end
    else
     begin
      if FileExists(ExpandConstant('{tmp}\Win7-KB3191566-x86.zip')) then
       begin
        ExtractTemporaryFile('7z32.exe');
        ExtractTemporaryFile('7z32.dll');
        ShellExec('open',ExpandConstant('{tmp}\7z32.exe'),ExpandConstant('x -y -oExtractedArchive ')+ExpandConstant('Win7-KB3191566-x86.zip'),'',SW_HIDE,ewWaitUntilTerminated,ResultCode);
        ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\ExtractedArchive\Win7-KB3191566-x86.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
       end;
      if FileExists(ExpandConstant('{tmp}\Win8.1-KB3191564-x86.msu')) then ShellExec('open',ExpandConstant('{sys}\wusa.exe'),ExpandConstant('{tmp}\Win8.1-KB3191564-x86.msu'),'',SW_SHOWNORMAL,ewWaitUntilTerminated,ResultCode);
     end;
   end;
end;

procedure DeinitializeSetup();
begin
  ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0);
  UnloadSkin();
end;

Последний раз редактировалось ErikPshat, 24-07-2019 в 13:39.

Это сообщение посчитали полезным следующие участники:

Отправлено: 13:30, 24-07-2019 | #355