jre 1.6 check and progress bar in inno - inno-setup

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.

Related

Inno Setup Check if file exist in selected destination location

I have created files for a program I want to make as an update.
I would like it, before the installation, to check whether the program is also in the standard directory, and if not the one itself the right directory can choose where the program is.
I have tried this:
[Files]
Source: "C:\Data"; DestDir: "{app}"; Flags: ignoreversion
[Code]
function NextButtonClick(PageId: Integer): Boolean;
begin
Result := True;
if (PageId = wpSelectDir) and not FileExists(ExpandConstant('C:\Program\Test\Test.exe')) then begin
MsgBox('YourApp does not seem to be installed in that folder. Please select the correct folder.', mbError, MB_OK);
Result := False;
exit;
end;
end;
But during the installation it does not check it.
Whether the program is available or not, it installs it anyway.
I hope someone can help me.
You have to use the {app} constant in the test to check the selected folder:
FileExists(ExpandConstant('{app}\Test.exe'))

Inno Setup will not create folder under C:\Users\Public - will instead do C:\Users\Public\Public Documents

I am using Inno Setup to build my installer and I have the C:\Users\Public folder hardcoded in my [Files] section to place some files (Inno Setup does not have a constant for this folder)
My goal is to have the install create a C:\Users\Public\MyApp folder with some files in it. However when I run the install, it is creating the folder here:
C:\Users\Public\Public Documents\MyApp
Is this a permissions issue where the installer doesn't have access to create a folder directly under C:\Users\Public?
[Files]
Source: "MyApp\db.mdf"; DestDir: "{drive:{src}}\Users\Public\MyApp"; Flags: ignoreversion;
I cannot reproduce your problem. For me your code works. I've tested it on Windows Vista, 7 and 10. It always installs to C:\Users\Public\MyApp.
Though I do not understand the {drive:{src}}. How does the drive of the Users folder relate to the drive of the installer? You should use the {sd} constant:
[Files]
Source: "MyApp\db.mdf"; DestDir: "{sd}\Users\Public\MyApp"; Flags: ignoreversion
But anyway, to resolve the path to the C:\Users\Public, you can use the PUBLIC environment variable:
[Files]
Source: "MyApp\db.mdf"; DestDir: "{%PUBLIC}\MyApp"; Flags: ignoreversion
It works since Windows Vista.
Alternatively, you can use SHGetKnownFolderPath with FOLDERID_Public. For an example code, see Constant for AppData\LocalLow?
If you need to support even Windows XP, where there is no C:\Users\Public folder or PUBLIC variable, you have to find out, what path your need to use there instead (probably C:\Documents and Settings\All Users), and implement a fallback using a scripted constant:
[Files]
Source: "MyProg.exe"; DestDir: "{code:GetPublicPath}\MyApp"; Flags: ignoreversion
[Code]
function GetPublicPath(Param: string): string;
begin
Result := GetEnv('PUBLIC');
if Result <> '' then
begin
Log(Format('PUBLIC is "%s"', [Result]));
end
else
begin
Result := GetEnv('ALLUSERSPROFILE');
Log(Format('PUBLIC is not set, ALLUSERSPROFILE is "%s"', [Result]));
end;
end;
And for others, it's worth noting that your need for resolve C:\Users\Public is very specific, related to this question: C++ app MDB in ProgramData copies to user's AppData folder when I dont want it to.
One usually does not want the C:\Users\Public, but C:\Users\Public\Documents (= {commondocs}) or C:\ProgramData aka C:\Users\All Users (= {commonappdata}).

Inno Setup: How to dynamically add files to the installation?

Is there a way to dynamically fill the [Dirs] and [Files] sections of an Inno Setup script?
Here is what I am trying to do:
during the install process, the user will select foo (foo matches a repository to get from our SCM)
Setup will run a batch to checkout foo from our SCM
then the content of foo must be added to the [Dirs] and [Files] sections of the script
Everything works fine except for the last step. I searched around and couldn't find explanations on how to do this. I have the feeling that my script should embed all the repositories of our SCM to then be able to copy only the selected ones to the destination directory.
Thanks for your help!
Regards,
See Inno Setup Prompt for external file location.
And add the recursesubdirs flag.
You may also need the createallsubdirs flag (assuming from your reference to the [Dirs] section).
[Files]
Source: "{code:GetScmPath}"; DestDir: "{app}"; \
Flags: external recursesubdirs createallsubdirs
[Code]
function GetScmPath(Param: string): string;
begin
Result := { make it return path to the checked out files }
end;

How to install Microsoft VC++ redistributables silently in 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..."

Backup files and restore them on uninstall with InnoSetup?

Consider the following:
I have two files, for example XXX.txt and YYY.txt
I want to install them to a folder (let's say files), in which there are already XXX.txt and YYY.txt files
I want to "back up" the two original files, renaming them to XXX.txt.backup and YYY.txt.backup
On uninstall I want to restore the two files to their original state
How can I achieve this with Inno Setup?
Add
[Files]
; Backup Function_Template
Source: "{app}\XXX.txt"; DestDir: "{app}"; DestName: "XXX.txt.bkup"; Flags: external skipifsourcedoesntexist uninsneveruninstall
That would move the existing file, and the flags will prevent from uninstalling it. Now in the code you can put
[Code]
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
OldFile: string;
begin
case CurUninstallStep of
usPostUninstall:
begin
OldFile := ExpandConstant('{app}\XXX.txt.bkup');
if FileExists(OldFile) then
RenameFile(OldFile, ExpandConstant('{app}\XXX.txt'));
end;
end;
end;
Source: "{app}\XXX.txt"; DestDir: "{app}"; DestName: "XXX.txt.bkup"; Flags: external skipifsourcedoesntexist uninsneveruninstall
Did not appear to work, since "The compiler will prepend the path of your installation's source directory if you do not specify a fully qualified pathname."
However, I just discovered this works fine! I had left off the "external" flag.
Well, maybe a popup saying "There is already an XXX.txt.backup. Do you really want to overwrite it?"

Resources