Reputation: 293
So I am getting an identifier expected error in Inno Setup Script IDE and I was wondering how to fix it. This is related to install a required dependency of the program if it does not exist. The Code is below:
[code]
function FrameworkIsNotInstalled: Boolean;
begin
Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.0');
end;
procedure InstallFramework;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing .NET framework...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
function isADBinstalled: Boolean; //error occurs on this line
begin
Result := not DirExists(ExpandConstant '{sd}\adb');
procedure installadb
var
StatusText: string;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing ADB this shouldnt be long...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\adb-setup-1.4.2.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('ADB Install failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
Upvotes: 1
Views: 3611
Reputation: 293
I managed to use the below answer and tweaked it a bit to fix the invalid number or parameters message:
Source: "C:\Users\James\Downloads\DotNet Framework 4.5.1.exe"; DestDir: {tmp}; Check: FrameworkIsNotInstalled;
Source: "C:\Users\James\Downloads\adb-setup-1.4.2.exe"; DestDir: {tmp} ; Check: ADBNotInstalled;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[code]
//check if .net 4.5 installed
function FrameworkIsNotInstalled: Boolean;
begin
Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\.NETFramework\policy\v4.0\Release');
end;
//install .net
procedure InstallFramework;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing .NET framework This may take a while...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
//check if adb is installed check is with setup installer
function ADBNotInstalled: Boolean;
begin
Result := not DirExists(ExpandConstant('{sd}\adb'));
end;
procedure InstallADB;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing ADB this will be just a second...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\adb-setup-1.4.2.exe'), '/q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('ADB Failed to install with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
Upvotes: 1
Reputation: 45243
You forgot the end
keywords for a couple of times.
function FrameworkIsNotInstalled: Boolean;
begin
Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.0');
end;
procedure InstallFramework;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing .NET framework...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end; // you forgot this
function isADBinstalled: Boolean; //error occurs on this line
begin
Result := not DirExists(ExpandConstant '{sd}\adb');
end; // you forgot this
procedure installadb; // you forgot the semicolon
var
StatusText: string;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing ADB this shouldnt be long...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\adb-setup-1.4.2.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('ADB Install failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end; // you forgot this
end;
You can avoid those mistakes by formatting your code properly. Everytime you type begin
you should directly type the corresponding end
. Do the same for brackets and quotes.
Upvotes: 3