How to install Microsoft VC++ redistributables silently in Inno Setup? - inno-setup

How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.
Here is my [Run] section's code:-
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/passive /verysilent /norestart /q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; \
Check: VCRedistNeedsInstall; WorkingDir: {app}\bin;Flags: runminimized nowait; \
StatusMsg: Installing CRT...

For a smooth install, check if it's necessary to install the redistributable. If the installed version is already up to date (quite likely), don't even unpack it.
[Files]
; VC++ redistributable runtime. Extracted by VC2017RedistNeedsInstall(), if needed.
Source: ".\Redist\VC_redist_2017.x64.exe"; DestDir: {tmp}; Flags: dontcopy
[Run]
Filename: "{tmp}\VC_redist_2017.x64.exe"; \
StatusMsg: "{cm:InstallingVC2017redist}"; \
Parameters: "/quiet"; Check: VC2017RedistNeedsInstall; Flags: waituntilterminated
[Code]
function VC2017RedistNeedsInstall: Boolean;
var
Version: String;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Version',
Version) then
begin
// Is the installed version at least 14.14 ?
Log('VC Redist Version check : found ' + Version);
Result := (CompareStr(Version, 'v14.14.26429.03')<0);
end
else
begin
// Not even an old version installed
Result := True;
end;
if (Result) then
begin
ExtractTemporaryFile('VC_redist_2017.x64.exe');
end;
end;
Note that the 14.14 redistributable is also suitable for VS2015.

You can add those to the setup script:
[Files]
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: deleteafterinstall
[Run]
Filename: {tmp}\vcredist_x86.exe; \
Parameters: "/q /passive /Q:a /c:""msiexec /q /i vcredist.msi"""; \
StatusMsg: "Installing VC++ 2008 Redistributables..."
Note that the run parameters will change slightly, if you are using a different redistributable version from 2008.

I modified the above code as follows. Then I got it worked properly and the entire installation was pretty smooth and silent.
[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
Parameters: "/q /norestart /q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; \
Check: VCRedistNeedsInstall; WorkingDir: {app}\bin;
Reference Links:
http://www.computerhope.com/cmd.htm
https://web.archive.org/web/20150925001652/http://blogs.msdn.com/b/astebner/archive/2014/03/08/10078468.aspx

Here is my solution:
Filename: "{tmp}\vc_redist.x86.exe"; Parameters: "/q /norestart"; \
Check: VCRedistNeedsInstall; StatusMsg: "Installing VC++ redistributables..."

Related

How to override a third-party installation directory with inno setup

I need to install a thirdparty software embedded in a installer named thirdparty-installer.exe and also install my application Instruct.exe. My application will be at c:\MyAPP folder and all my thirdparty files must be at c:\windows\system32 (all files will be thrown there, in the system32 root). I have done the following:
#define OutputDirectory_MPP "c:\myAPP"
[setup]
DefaultDirName=c:\MyAPP
DisableDirPage=yes
[dirs]
Name: {#OutputDirectory_MPP}; Attribs: system
[files]
Source: "g:\application\Instruct.exe"; DestDir: {#OutputDirectory_MPP}
Source: "g:\applicationr\thirdparty-installer.exe"; DestDir: "{cf}"; Flags: ignoreversion recursesubdirs createallsubdirs promptifolder; Permissions: system-full;
[Run]
Filename: "{cf}\thirdparty-installer.exe"; Flags: shellexec waituntilterminated
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
(...)
My Instruct.exe installs normally, and when it finishes, the thirdparty-installer prompts and show the user the option to change installation directory. Their default is c:\program files\Thirdparty2020\
How can I impose their installation to be on the c:\windows\system32 folder and leave no option to the user? (possibly even coupled with a silent install).

How to open a INI file with Notepad.exe in [Run] section?

In Inno Setup, how can i open an INI file with Notepad.exe using the [Run] section?
This is what i have, but its getting "%1 is not a valid win32 program"...
[Run]
Filename: "{app}\data.ini"; Description: "Check here see data."; Flags: postinstall runascurrentuser skipifsilent unchecked;
What i need is to open that file in user notepad after finishing the installation, if the user checked that checkbox.
Maybe its easier to do with code, but i am not sure how to do it.
Thanks.
Try this:
Filename: "notepad"; Parameters: {app}\data.ini; Description: "Check here see data."; Flags: postinstall runascurrentuser skipifsilent unchecked;

Error running .exe file in Inno setup

I am trying to make my script run this file:
http://www.microsoft.com/en-us/download/details.aspx?id=40779
before/after (doesn't matter) I install my application.
This is my script:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; Flags: skipifsilent
[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={{AEDD3A70-5044-452B-B78D-9CCE4E130654}
AppName=Pong
AppVersion=2.0
;AppVerName=Pong 2.0
AppPublisher=Roymunson_Studios
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={pf}\Pong
DefaultGroupName=Pong
AllowNoIcons=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Run]
Filename: "{app}\Installers\NDP451-KB2858728-x86-x64-AllOS-ENU.exe"; StatusMsg: "Installing .NET Framework 4.5.1"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "C:\Users\vroy\Desktop\Debug\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{commondesktop}\Pong"; Filename: "{app}\Pong.exe";
However when it tries to compile the .NET 4.5.1 installer file it shows the following error:
"The process cannot access the file because it is being used by another process"
This makes no sense because the .NET 4.5.1 installer is not being used when I am compiling my Inno script.

Inno Setup : How to set installer "Run As Administrator"?

In Inno Setup,
[Setup]
PrivilegesRequired=admin
is still can not Run the installer as Administrator, but I need to Launch my Program at last step of Inno Setup.
How can I do to set my Installer can Run as Administrator ?
I have been having this same problem as well, it took me quite a bit of time to figure out that after you have set the PrivilegesRequired=admin you also need to add runascurrentuser to all the Flags under [Run] section.
[Setup]
PrivilegesRequired=admin
[Run]
Filename: "{app}\MyApp.exe"; Description: "{cm:LaunchProgram,MyApp}"; Flags: runascurrentuser nowait postinstall skipifsilent; Check: returnTrue()
Filename: "{app}\MyApp.exe"; Flags: runascurrentuser; Parameters: "-install -svcName ""MyApp"" -svcDesc ""MyApp"" -mainExe ""MyApp.exe"" "; Check: returnFalse()
I know you have probably already figured out the issue considering this question was asked over two years ago but I thought I would answer it anyway for others like myself who found this unanswered question but would have really liked to have seen an answer.
My inno setup script is belowing,
#define MyAppName "MyApp"
#define MyAppExeName "MyApp.exe"
[Setup]
PrivilegesRequired=admin
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: runascurrentuser nowait postinstall skipifsilent

jre 1.6 check and progress bar in inno

I want to check whether hre 1.6 or higher is installed or not. If installed I want to progress my application. If not installed , I want to install jre-6u17-windows-i586-s.exe after successfully installing jre , my control not returns to inno again. Please send a inno script for that.
best regards
SOumen
For the [FILES] section:
[Files]
Source: "jre-6u17-windows-i586-s.exe"; DestDir: "{app}\JRE 1.6"; Flags: onlyifdoesntexist
For the [CODE] section:
[Code]
Function JREInstallPrompt:Boolean;
begin
if ((msgBox ('Do you want to install JRE 1.6?',mbinformation,mb_YesNo)=idYes)) then
begin
msgBox ('JRE 1.6 will being installing now. Please do not restart the machine or log off until it is complete!',mbinformation,mb_OK);
Result:=True;
end
else Result:=False;
end;
Function JREVerifyInstall:Boolean;
begin
if ((RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\JavaSoft','InstallerVersion')) or (JREInstallPrompt=False)) then //Exists or do not install
Result:=False
else Result:=True;
end;
And for the RUN section:
[Run]
;SQL Server Express 2005 Installer
Filename: "{app}\JRE 1.6\jre-6u17-windows-i586-s.exe"; WorkingDir: {app}\JRE 1.6; StatusMsg: Installing Java Runtime Environment... Please Wait...;Check:JREVerifyInstall
Hopefully that will get you pointed in the right direction.

Resources