我正在尝试使用 Microsoft 的 Desktop App Converter 将我使用 inno-setup 制作的 Install .exe 文件转换为 appx 文件。它每次都挂在“等待安装程序处理以在隔离环境中完成”。
我在 Desktop App Converter 中使用的命令是:
DesktopAppConverter.exe -Installer "C:\Users\Desktop\Output\setup.exe" -Destination "C:\Users\Desktop\MyProgram\" -PackageName "MyProgramApps" -Publisher "Me"
-Version 0.1.4.0 -MakeAppx -Verbose -InstallerArguments "/VERYSILENT" -PackagePublisherDisplayName "MyApps" -PackageDisplayName "MyProgram" -AppDisplayName "MyProgram" -AppId "MyProgram"
当我使用“/VERYSILENT”从命令行运行“MyProgram.exe”时,它会完全静默安装。
Inno-Setup 的脚本是:
#define MyAppName "MyProgram"
#define MyAppVersion "0.1.7"
#define MyAppPublisher "MyApps"
#define MyAppExeName "MyProgram.exe"
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\Desktop\Output
OutputBaseFilename=thirteenth_setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\Desktop\resources\MyProgram.exe"; DestDir: "{app}"; Flags: ignoreversion
#define JavaInstaller "jre-8u151-windows-x64.exe"
Source: "{#JavaInstaller}"; DestDir: "{tmp}"; Flags: dontcopy
[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; \
Description: "{cm:LaunchProgram,{#StringChange(MyAppName,'&', '&&' )}}"; \
Flags: nowait postinstall skipifsilent
[Code]
const
REQUIRED_JAVA_VERSION = '1.7';
function isJavaInstalled(): Boolean;
var
JavaVer : String;
tmpFileName,
pathJavaExe: String;
isGoodJavaVersion,
isFoundJavaPath: Boolean;
ResultCode: Integer;
ExecStdout: AnsiString;
begin
{ *** check in registry }
{ sets variables: }
{ JavaVer }
{ isGoodJavaVersion }
if RegQueryStringValue(HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment',
'CurrentVersion', JavaVer) AND (JavaVer <> '') OR
RegQueryStringValue(HKLM64, 'SOFTWARE\JavaSoft\Java Runtime Environment',
'CurrentVersion', JavaVer) AND (JavaVer <> '') then begin
Log('* Java Entry in Registry present. Version: ' + JavaVer);
isGoodJavaVersion := CompareStr(JavaVer, REQUIRED_JAVA_VERSION) >= 0;
end;
{ add additional checks, for example by searching the PATH, }
{ or by running `java -version` }
Result := isGoodJavaVersion;
end;
procedure ExtractInstaller;
begin
ExtractTemporaryFile('{#JavaInstaller}');
end;
[Run]
Filename: "{tmp}\{#JavaInstaller}"; Parameters: "SPONSORS=0"; \
StatusMsg: "Java Runtime Enviroment not installed on your system. Installing..."; \
Check: not isJavaInstalled; BeforeInstall: ExtractInstaller;
我认为这与以下方面有关:
[Run]
Filename: "{tmp}\{#JavaInstaller}"; Parameters: "SPONSORS=0"; \
StatusMsg: "Java Runtime Enviroment not installed on your system. Installing..."; \
Check: not isJavaInstalled; BeforeInstall: ExtractInstaller;
因为当我在没有那个“运行”语句的情况下运行它时,DAC 就会运行到完成。但是当然 Java 安装程序不会运行。