MSI for Visual C++ 2015 - installation

I need to install redistributable Visual C++ 2015 on three hundred computers in a corporate office. Is there any way to convert EXE to MSI. It would save tons of time.

The Visual Studio 2015 and 2017 installers are built with the WiX toolset.
You can extract the contents of these with the dark tool:
+>dir /b vc_*
vc_redist.x64.exe
vc_redist.x86.exe
+>mkdir x64-extracted
+>c:\local\WiX-3.11.1-bin\dark.exe vc_redist.x64.exe -x x64-extracted
Windows Installer XML Toolset Decompiler version 3.11.1.2318
Copyright (c) .NET Foundation and contributors. All rights reserved.
vc_redist.x64.exe
+>cd x64-extracted
+>dir /b /s
....\vcredist-2015\x64-extracted\AttachedContainer
....\vcredist-2015\x64-extracted\UX
....\vcredist-2015\x64-extracted\AttachedContainer\packages
....\vcredist-2015\x64-extracted\AttachedContainer\packages\Patch
....\vcredist-2015\x64-extracted\AttachedContainer\packages\vcRuntimeAdditional_amd64
....\vcredist-2015\x64-extracted\AttachedContainer\packages\vcRuntimeMinimum_amd64
....\vcredist-2015\x64-extracted\AttachedContainer\packages\Patch\x64
....\vcredist-2015\x64-extracted\AttachedContainer\packages\Patch\x86
....\vcredist-2015\x64-extracted\UX
...
+>
This will contain the vc_runtimeMinimum_x64.msi along with a cab1.cab that contains the actual data and the vc_runtimeAdditional_x64.msi along with another cab1.cab with the MFC dlls.
Note that it will also contain a bunch of MSU files (under the ..\Patch\..) subdir, that contain operating system patches for a minimum version of the Universal C Runtime. The UCRT is the part of the C runtime library that is no longer VS version specific, but an OS component.

I looked for a solution for that, too but couldn't find a way.
I just deploy it with powershell with silent switch like this:
& "\\MyServer\path\vc_redist.x86.exe" /q /norestart | Out-Null

Have you tried to extract it, as in the this example?

You can use a tool that converts a setup executable file (EXE) into a Windows Installer Package (MSI):
QwertyLab's Exe to Msi Converter (Free): download
EMCO MSI Package Builder (Shareware): download
You can download and use an evaluation version during a trial period. If you would like to continue using the product after the trial period, you must purchase the license. License removes any trial version limitations, so you don't need to download another copy of the product.
MSI package are useful to be deployed via GPO of Microsoft Active Directory.
Also, There other approach than GPO using EMCO Remote Installer.
EMCO Remote Installer perform any complex deployment task with just a few clicks. The application automates software deployment and audit operations, so you can easily manage software across your entire network. Review feature list

Related

Installing VC_REDIST.X86 quietly using InstallShield Lite

I have been pulling out what's left of my hair trying to install software that requires a C++ redistributable (2017 x86) using InstallShield lite.
To start with, I define a prerequisite To include the C++ redistributable. When a user attempts an install, the user interface always appears. Now this is not a real problem however, if the redistributable was already installed`or there is a newer version then it will fail with a message that it has failed and it wioll ask the user if he wants to continue or abort the installation. If he selects continue, the software installs fine. This is not very user friendly.
This happens despite the correct command line switches being used i.e. /q /norestart. If you do this at a command prompt manually, it operates as it should. In other words it installs it, or fails because it is already installed but tells the user nothing. This is the way it is supposed to work.
Now I tried doing this as a custom action at the end of the installshield script but then the install appears to hang on some machines and on others other errors.
Now the only clue that I can give, is that if I create an MSI installation, then it never prompts. However with a setup.exe install it acts as above. I have only been successful with the msi install if I am installing a 64 bit app. Never with a 32 bit app.
Can someone guide me as to what I am doing incorrectly?
Thanks
VCRedist: This C / C++ runtime (in various versions and flavors) is a pain indeed. I decided to write something up a while back to try to summarize a few things:
Wix per user installer to detect the Visual C++ 2015 Redistributable (please skim at least - not great, better than nothing I hope - deals mostly with detecting the presence of the runtime).
Merge Modules: Does Installshield Lite support merge modules? If so, you can install the VCRedist using merge modules instead of the VCRedist_x64.exe file. This is insufficient for UWP applications (the universal CRT) as explained in these links:
Redistributables for deploying C++ exe developed with Visual Studio 2015 on Windows 7
WIX merge c++ runtime
Do read the links directly above - they are quick reads.
Batch File: Another option would be to keep the VCRedist_x64.exe file separate from your main setup and to zip up your MSI and the VCRedist_x64.exe in a ZIP archive and put an Install.cmd batch file in there which will install the VCRedist first and then your MSI file? Not too neat - one would have to admit. I think you can make a self-extracting archive that would automagically invoke it, but I haven't done that in ages.
Just a mock-up batch file from link below (untested):
REM 1. Install VCRuntime
vc_redist.x64.exe /install /quiet /log "%temp%\Install_vc_redist_2017_x64.log"
REM 2. Install MSI
msiexec.exe /i MySetup.msi /L*v C:\MySetup.log /QN
Not sure about security fixes and that kind of stuff. Run Windows Update afterwards?
Security Fixes & Link to Download: There have been so many security fixes for this runtime, and it is usually installed on most machines, that I would frankly just link to the download of the latest version and have people install it themselves as a pre-requisite rather than bundling an obsolete version in my setup, but that isn't really sufficient unless your package is for corporate use only (in which case they prefer to install their own runtimes with full control).
Some Links (to find easily):
Command lines to install and uninstall silently the VC++ 2017 Redistribuables (installation command lines, untested by me)
The latest supported Visual C++ downloads (please check)
Microsoft Visual C++ 2017 Resitributable Package (x86) (please do read this)
How to prevent vc_redist.x##.exe (VS2017) from ambiguously failing due to pending reboot?
Visual Studio 2017 Installer Project - include VC++ 2015 Redistributable
There is always the WiX toolkit
Distributable Code for Microsoft Visual Studio 2017 (Includes Utilities, Extensibility, and BuildServer Files)
Mailbag: How to perform a silent install of the Visual C++ 2010 redistributable packages
Thanks for a comprehensive answer. I am sure it will help a lot of people. What I have found is that running vc_redist.x86 from the command line in quiet mode will indeed always work as it should. In other words, if it is not installed, it will be installed. If it is already installed or a later release is installed, it will just return with no complaints. That is not the case using InstallShield Lite 2018 (same for all previous releases).
However, there is a simple solution to get it to work as I found out. All one needs to do is to include the entry Hidden="1" in the behavior part of the PRQ file. So there will now be an entry that looks like this:
<behavior Hidden="1" Failure="4" Reboot="2"/>
This solves the issue. It no longer runs separately from the installshield installer with it's own GUI but rather the messages now appear in the menus in installshield and it operates exactly as if you ran it at the command line. No more errors.

Error Creating a 7-zip installer package

If this is not the correct place to ask this, I apologize.
I use 7zip to create an installer package. Recently, my computer was updated, and I can no longer get it to work. I use a Windows Installer from Visual Studio 2010 to create the installation package, which I add to a file called setup.7z. I have confirmed that the files are archived correctly. I then call
copy /b 7zsd.sfx + config.txt + setup.7z setup.exe
which packages everything into a single file called "setup.exe". Clicking on this would start the installer.
After the update, I can still make the file, and it looks just fine. However, if I try to click on it, I get a message saying 7-Zip: Unsupported method.
I have 7-Zip version 18.05 (x86) installed. Honestly, I am not sure where I got the 7zsd.sfx file, but do remember having to hunt it down. It has no versioning, but was last modified on 7/13/2007. I don't know if the version matters, since you shouldn't need 7-Zip installed since this is a self-extracting file. However, it may be that the older version isn't able to unzip something zipped by a newer version.
I think the problem is in different versions of 7zip and 7zip.sfx used. Unfortunately SFX file is absent in most recent 7zip packages.
Here is link to 7zip_extra from some old version that has both SFX file and .bat file to create the installer.
Works fine for me.
Setup Tools: Why 7-Zip? There is a plethora of alternatives for creating (real) setups - and several are free: How to create windows installer (several links to tools for creating all kinds of setups). Brief descriptions below as well - under "Alternatives" (free tools, or tools with free features). These tools have been tested extensively to ensure running with minimal dependencies. Just something to keep in mind and evaluate I guess.
7-Zip
Guess: first install the C/ C++ runtimes and see if the problem goes away. Next check the compression - and then the LZMA SDK
as described below?
Unsupported Compression?: 7-Zip: Unsupported method - use LZMA? I suppose this problem could still occur though that answer is a couple of years old.
Missing Runtime?: You might also want to do a dependency walker check on that setup.exe to see if it depends on something that is missing on the box (for example MSVCRT.dll - or another runtime library). Just download the tool. Easy to use. Or maybe first try to install commonly used C/C++ runtimes. Also, Dependency Walker is aging and shows garbage at times. There is the newer Dependencies - but it is not quite prime-time yet, but try it (click Releases tab). It has been updated to handle Windows API-sets and WinSxS (side-by-side assemblies). Note: several security software on virustotal.com detect Dependencies as a "risk tool, not a virus" (it is open source).
LZMA SDK: The 7zSD.sfx file would likely be from the LZMA SDK. And the command line you describe can be found in the main 7-Zip help file (not the SDK, but the one coming with the regular 7-zip installation). Section "-sfx (Create SFX archive) switch" : Command Line Version => Switches => -sfc (Create SFX Archive.
Alternatives
Visual Studio 2017: The newest, free version of Visual Studio: Visual Studio Community 2017 can create setup.exe files via its Microsoft Visual Studio 2017 Installer Projects (this extension must be installed after installing Visual Studio 2017).
WiX: The Open Source WiX toolkit can create setup.exe files with its Burn component. A WiX Burn ad-hoc sample- just to get the general idea - it has a learning curve. No GUI to help you, it is all XML-based. Use with or without Visual Studio.
Advanced Installer: I believe Advanced Installer can compile a setup.exe even in their free version. Despite a somewhat large download, I think this would work for you and be quick.
UPDATE on Advanced Installer: The free edition can only build MSI files, EXE bootstrappers can be built with the paid editions (any of them).
dotNetInstaller: There is also the dotNetInstaller Setup Bootstrapper - which I have never used. Here it is on github.com (source).
Inno or NSIS: These free non-MSI installers can easily create a setup.exe for you that has been
optimized for minimal dependencies. I haven't used them much, but they
are well-known. NSIS seems to create archive files compatible with Zip tools.
IExpress et al: There are security vulnerabilities that affect these self-extracting packages. Another reason I recommend a "real" deployment tool with dedicated resources to fix such things quickly, despite the niceness of having a setup.exe that can be opened directly in 7-zip.
File Extraction
On the topic of extracting files from setup.exe files of various types:
MSI: Extract MSI from EXE - all MSI files can be extracted, and setup.exe files created with WiX can also be extracted
NSIS & Inno: It looks like NSIS creates files compatible with 7-Zip (comprehensible compression), not so with Inno by the looks of it.
Some Links:
Wix and .NET Framework (prerequisites)
What is the difference between 7zip's 7z.sfx and 7zsd.sfx?
https://en.wikipedia.org/wiki/Self-extracting_archive#Overview : "For a decompression utility to correctly expand an archive of either
the self-extracting or standard variety, it must be able to operate on
both the file format and algorithm used. The exact executable code
placed at the beginning of a self-extracting archive may therefore
need to be varied depending on what options were used to create the
archive. The decompression routines will be different for a LZMA 7z
archive when compared with a LZMA2 7z archive, for example."

Redistributables for deploying C++ exe developed with Visual Studio 2015 on Windows 7

I have developed a 32-bit C++ application using Visual Studio 2015 (on Windows 10). I want to deploy it onto machines running Windows 7 and later.
I put together a WiX installer and included the VC++ redistributable merge module as described here. The merge module I included was C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC140_CRT_x86.msm.
This installer appears to work fine but on Windows 7 the installed program will not run, complaining about missing api-ms-win-crt-runtime-l1-1-0.dll.
From searching I suspect that there may be extra files in the redistributable package vc_redist.x86.exe from here, but the WiX docs tell me to use an msm rather than an exe.
It's also possible that the merge module failed to install. I didn't see any errors but I haven't re-run it with logs enabled to check that possibility.
Another option may be to use burn but I am not familiar with this tool; I will go that route if it's the correct one but I'd prefer to stick with MSI if possible.
The VC++ runtime redistributables got more complicated in Visual Studio 2015. See the VC team blog post about the universal CRT. Basically, the merge module is insufficient:
There will not be a merge module for the Universal CRT. If you currently use the CRT merge modules and still want to deploy the Visual C++ libraries centrally, we recommend that you move to the above mentioned Windows Update package or to the VCRedist. Alternatively, you may choose to link statically to the Universal CRT and the Visual C++ libraries.
We ran into the trouble that the MSI package failed to install the redistributable with MSI Error 1618: 'Another installation is already in progress' during installation/uninstallation. We installed the 2015 redistributable with WIX by using a Bootstraper. For example:
<Chain>
<!-- Microsoft Visual C++ 2015 x86 libraries -->
<ExePackage Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
SourceFile="EXAMPLE_PATH\vc_redist.x86.exe" InstallCommand="/install /passive /norestart">
</ExePackage>
<MsiPackage Id="MainPackage" SourceFile="YOUR_MSI_PACKAGE.msi" DisplayInternalUI="no" Compressed="yes" Vital="yes"/>
</Chain>
It's worth noting that it is now possible to distribute the Universal C Runtime DLLs with your application. The MSDN blog post describes the steps:
Install the Windnows 10 SDK
Go to C:\Program Files (x86)\Windows Kits\10\Redist\ucrt and find the DLLs for the platform you are targeting
Copy them into your application's program directory
They are not big. About 2 megabytes in total.
I ended up using this technique because:
It does not require me to create a separate WiX package and then bootstrap them;
It does not require the user to run any extra installers
I cannot speak to whether it would work on all computers, but it works on the ones I have tested.

How to include MFC and Visual Studio CRT libraries into MSI installer?

I'm trying to learn how to write MSI installer. I'm using WiX, and I'm curious. My application comes with the dependencies to the followign MFC and CRT libraries:
mfc90u.dll
msvcr90.dll
How do you install those?
There are some choices listed here. I recommend using the appropriate redistributables instead of installing individual DLLs.
With WiX 3.6 and later, you can create a chainer that runs multiple installers. You can create a VS project for that with a WiX Bootstrapper template.
Distibuting the vcredist dlls as private DLLs creates security risks for the user, and is discouraged, however if you distribute the version mentioned it must live in a subfolder of the app folder with a name specified in msdn docs. It is far better to use the vcredist exe (even if your app does not need all of the vc redist files),or the related msm. The location of the msm or private dlls is part of your VS installation and detailed in the VS redistribution license. The vcredist exe is available from microsoft's site. There are many different versions of the vs 2008 redist. Open your binary in a text editor and search for manifest to read the embedded manifest which details which version of the vcredist you need to deploy. Never take anything from the SXS folder. Regarding wix you can add the msm to your msi but there are issues with doing that. The prefered method is create a Wix bundle using the vcredist exe.

Deploying DirectX/MFC app with Visual Studio 2010 Professional

I am able to run my app through the VS2010 environment. But cannot make it working as a stand-alone exe (to run it just by double click on exe). I don't know what files are required.
In VS in Additional Dependencies I have:
d3d11.lib
d3dcompiler.lib
d3dx11d.lib
d3dx9d.lib
dxerr.lib
dxguid.lib
winmm.lib
comctl32.lib
I tried to copy these files to the same directory where my exe is:
d3d11.dll
d3dcompier_43.dll
d3dx9d_43.dll
d3dx11d_43.dll
I also tried to find some dependencies, but the dependency walker crashes with some errors. So I used dependency scanner in InstallShield 2010, it said:
d3dx11d_43.dll
Microsoft (R) C Runtime Library
Microsoft OLE 2.40 for Windows NT(TM) and Window 95(TM) Operating Systems
VC User gdiPlus RTL X86
What are the last three things? What else can I do?
// EDIT
The app has been created by using DirectX SDK June 2010, so I have installed the DX End User June http://www.microsoft.com/en-us/download/details.aspx?id=8109 .
However, the app is working throught the VS2010, but the stand-alone exe (on the same computer) doesn't work, so I think the DX End User wasn't even necessary if I had SDK (the Visual C++ Redist was installed too).
I also tried to create a setup via VS2010, it copied these files:
COMDLG32.dll
d3d11.dll
d3dx11d_43.dll
IMM32.dll
MSIMG32.dll
OLEACC.dll
oledlg.dll
but it still doesn't work (while clicking on the exe it always displays the: Program xyz has stopped working. Windows can find a solution to this problem online. Find/Close/Debug buttons.)
Maybe it is something with the MFC?
Instead of just copying those DLLs, you'll need to install the DirectX End-User Runtime (the correct version, matching your development environment) on the user's system, as well as the Microsoft Visual C++ Runtime.

Resources