How to Check for Absence of a File - makefile

I am trying to use nmake to create and then test my installer and uninstaller. While creation and uninstallation can be checked out of the box I cannot figure out how to check that a file got removed after uninstall.
Thanks
HG
?: InstalledFile.txt
Setup.exe --uninstall
InstalledFile.txt: Installer
Setup.exe
Installer: Setup.exe
InstallerAssembler.py -p=Complex.xml -t=Complex
Setup.exe:
p4 sync $(VIEW)
devenv ...

make isn't very good at representing negative logic.
The standard workaround, I believe, is to create a dummy file:
InstalledFile.txt.isabsent:
(some command that creates the target if InstalledFile.txt does not exist, and fails otherwise)

Related

Make installer use local .msi file

I'm using a Visual Studio Installer Project (.vdproj) to create an installer. When built, it outputs an .msi file and a setup.exe file. When I run the setup.exe, it downloads the .msi from the location specified in the "Installation URL" field in project build properties, and runs it. However, if the PC is offline, the download fails and the install is aborted, although the .msi file is present in the same directory as the .exe file. Is it possible to configure the setup.exe to use the local .msi file if present?
In the Visual Studio Prerequisites you should be able to use the "Download Prerequisites from the same location as my application". This generates a directory (a CD image if you like) that will be used to install the prerequisites. It won't install anything from there unless you build the prerequisites that way. Also, you can't just add a framework with the right name because there's a hash check to ensure that the actual prerequisite redistributable is the correct one.

Windows installer and setup.exe

I've Visual Studio setup project for creating installation for my project. After build Visual Studio create two files: *.msi file and setup.exe file.
MSI file contain all project files, information about destination, registry entries, etc. Setup.exe just bootstrapper for running msi file, but end-user is able run only msi file without setup.exe and program will be installed correctly.
What setup.exe do? Should we run installer only using setup.exe or we can distribute our product without setup.exe?
Yup .MSI version is enough.
Check this other post.
What are the benefits of a MSI installer over a standard setup.exe?
Best Regards

how to include "MSVC Runtime.exe" in my MSI installer proj, and have it be run if it's not installed?

i want to have the "vcredist_x86.exe" included in my installer package.
requirements:
1) built in to the msi file, not a separate package, not a separate install
2) runs automatically as part of single installer
3) only runs if not already installed
4) does not leave extra copy of itself on users hard drive
5) succeeds to build installer file from command line scripts
6) installer must succeed when run
what i tried:
1) project->properties->config props->build->Prerequisites, then check "Create setup program to install prereq components", then check "Visual C++ Runtime Libraries"
problems: violates all requirements except 6, which is moot.
2) in installer pro, show "File System", then add "vcredist_x86.exe" to the user's desktop or application folder, then under "Custom Actions", under "Install", right click->Add Custom Action, then pick "vcredist_x86.exe" from the install location. then select it, then in "Properties" under "Arguments", change "/Install" to "/Install /qb!" (this should cause the install to be "Unattended install with no cancel button"
problems: violates requirements 3, 4 and 6. As to 6: when running the installer, it fails with the message "There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor." That would be me, and i do not know what to do.
Let's start with some prerequisite rules and best practices:
they use separate packages
installed only when required
handled by an EXE bootstrapper
most of them cannot run as part of the main MSI installation process
Most of these break your requirements. Another approach is using the Visual Studio merge modules from "C:\Program Files\Common Files\Merge Modules":
http://msdn.microsoft.com/en-us/library/ms235290.aspx
http://msdn.microsoft.com/en-us/library/8x727h8b.aspx
Visual Studio setup projects cannot install merge modules conditionally, so they will always be installed. Other setup authoring tools allow you to condition merge modules based on their associated feature:
create a search which determines if the merge module is installed or not
condition the merge module feature with that search result
A third option would be to include just your application dependencies:
http://msdn.microsoft.com/en-us/library/ms235317(VS.90).aspx
In this case only your application will have access to the runtime. This approach supports conditional install:
create a search which determines if the runtime is installed
use that search to condition each dependency file
Okay, the solution was to use IExpress and have the thing it executes be a shell script (.bat file).
in the .bat file, have it create the "vcredist_x86" folder and move the "vcredist_x86.exe" into it, then just run setup.exe
this meets all my original requirements.

Extract MSI from EXE

I want to extract the MSI of an EXE setup to publish over a network.
For example, using Universal Extractor, but it doesn't work for Java Runtime Environment.
For InstallShield MSI based projects I have found the following to work:
setup.exe /s /x /b"C:\FolderInWhichMSIWillBeExtracted" /v"/qn"
This command will lead to an extracted MSI in a directory you can freely specify and a silently failed uninstall of the product.
The command line basically tells the setup.exe to attempt to uninstall the product (/x) and do so silently (/s). While doing that it should extract the MSI to a specific location (/b).
The /v command passes arguments to Windows Installer, in this case the /qn argument. The /qn argument disables any GUI output of the installer.
Quick List: There are a number of common types of setup.exe files. Here are some of them in a "short-list". More fleshed-out details here
(towards bottom).
Setup.exe Extract: (various flavors to try)
setup.exe /a
setup.exe /s /extract_all
setup.exe /s /extract_all:[path]
setup.exe /stage_only
setup.exe /extract "C:\My work"
setup.exe /x
setup.exe /x [path]
setup.exe /s /x /b"C:\FolderInWhichMSIWillBeExtracted" /v"/qn"
dark.exe -x outputfolder setup.exe
dark.exe is a WiX binary - install WiX to extract a WiX setup.exe (as of now). More (section 4).
There is always:
setup.exe /?
Temp Folder: And the last resort: launch the installer and then look for extracted files in the temp folder (more details below).
Real-world, pragmatic Installshield setup.exe extraction.
Installshield: Setup.exe and Update.exe Command-Line Parameters.
Installshield setup.exe commands (sample)
Wise setup.exe commands
Advanced Installer setup.exe commands.
MSI Extract: msiexec.exe / File.msi extraction:
msiexec /a File.msi
msiexec /a File.msi TARGETDIR=C:\MyInstallPoint /qn
msiexec.exe command lines.
Microsoft's msiexec.exe documentation on MSDN.
Many Setup Tools: It is impossible to cover all the different kinds of possible setup.exe files. They might feature all kinds of different command line switches. There are so many possible tools that can be used. (non-MSI,MSI, admin-tools, multi-platform, etc...).
NSIS / Inno: Commmon, free tools such as Inno Setup seem to make extraction hard (unofficial unpacker, not tried by me, run by virustotal.com). Whereas NSIS seems to use regular archives that standard archive software (7-zip et al) can open and extract.
General Tricks: One trick is to launch the setup.exe and look in the 1) system's temp folder for extracted files.
Another trick is to use 2) 7-Zip, WinRAR, WinZip or similar
archive tools to see if they can read the format. Some claim success
by 3) opening the setup.exe in Visual Studio. Not a technique
I use. 4) And there is obviously application repackaging -
capturing the changes done to a computer after a setup has run and
clean it up - requires a special tool (most of the free ones
come and go, Advanced Installer Architect and AdminStudio are big
players).
UPDATE: A quick presentation of various deployment tools used to create
installers:
How to create windows installer (comprehensive links).
And a simpler list view of the most used development tools as of now (2018), for quicker reading and overview.
And for safekeeping:
Create MSI from extracted setup files (towards bottom)
Regarding silent installation using Setup.exe generated using Installshield 2013 (.issuite) project file (different kinds of Installshield setup.exe files)
What is the purpose of administrative installation initiated using msiexec /a?.
Just a disclaimer: A setup.exe file can contain an embedded MSI, it can be a legacy style (non-MSI) installer or it can be just a regular executable with no means of extraction whatsoever. The "discussion" below first presents the use of admin images for MSI files and how to extract MSI files from setup.exe files. Then it provides some links to handle other types of setup.exe files. Also see the comments section.
UPDATE: a few sections have now been added directly below, before the description of MSI file extract using administrative installation. Most significantly a blurb about extracting WiX setup.exe bundles (new kid on the block). Remember that a "last resort" to find extracted setup files, is to launch the installer and then look for extracted files in the temp folder (Hold down Windows Key, tap R, type %temp% or %tmp% and hit Enter) - try the other options first though - for reliability reasons.
Apologies for the "generalized mess" with all this heavy inter-linking. I do believe that you will find what you need if you dig enough in the links, but the content should really be cleaned up and organized better.
General links:
General links for handling different kinds of setup.exe files (towards bottom).
Uninstall and Install App on my Computer silently (generic, but focus on silent uninstall).
Similar description of setup.exe files (link for safekeeping - see links to deployment tools).
A description of different flavors of Installshield setup.exe files (extraction, silent running, etc...)
Wise setup.exe switches (Wise is no longer on the market, but many setup.exe files remain).
Extract content:
Extract WiX Burn-built setup.exe (a bit down the page) - also see section directly below.
Programmatically extract contents of InstallShield setup.exe (Installshield).
Vendor links:
Advanced Installer setup.exe files.
Installshield setup.exe files.
Installshield suite setup.exe files.
WiX Toolkit & Burn Bundles (setup.exe files)
Tech Note: The WiX toolkit now delivers setup.exe files built with the bootstrapper tool Burn that you need the toolkit's own dark.exe decompiler to extract. Burn is used to build setup.exe files that can install several embedded MSI or executables in a specified sequence. Here is a sample extraction command:
dark.exe -x outputfolder MySetup.exe
Before you can run such an extraction, some prerequisite steps are required:
Download and install the WiX toolkit (linking to a previous answer with some extra context information on WiX - as well as the download link).
After installing WiX, just open a command prompt, CD to the folder where the setup.exe resides. Then specify the above command and press Enter
The output folder will contain a couple of sub-folders containing both extracted MSI and EXE files and manifests and resource file for the Burn GUI (if any existed in the setup.exe file in the first place of course).
You can now, in turn, extract the contents of the extracted MSI files (or EXE files). For an MSI that would mean running an admin install - as described below.
There is built-in MSI support for file extraction (admin install)
MSI or Windows Installer has built-in support for this - the extraction of files from an MSI file. This is called an administrative installation. It is basically intended as a way to create a network installation point from which the install can be run on many target computers. This ensures that the source files are always available for any repair operations.
Note that running an admin install versus using a zip tool to extract the files is very different! The latter will not adjust the media layout of the media table so that the package is set to use external source files - which is the correct way. Always prefer to run the actual admin install over any hacky zip extractions. As to compression, there are actually three different compression algorithms used for the cab files inside the MSI file format: MSZip, LZX, and Storing (uncompressed). All of these are handled correctly by doing an admin install.
Important:
Windows Installer caches installed MSI files on the system for repair, modify and uninstall scenarios. Starting with Windows 7 (MSI version 5) the MSI files are now cached full size to avoid breaking the file signature that prevents the UAC prompt on setup launch (a known Vista problem). This may cause a tremendous increase in disk space consumption (several gigabytes for some systems). To prevent caching a huge MSI file, you should run an admin-install of the package before installing. This is how a company with proper deployment in a managed network would do things, and it will strip out the cab files and make a network install point with a small MSI file and files besides it.
Admin-installs have many uses
It is recommended to read more about admin-installs since it is a useful concept, and I have written a post on stackoverflow: What is the purpose of administrative installation initiated using msiexec /a?.
In essence the admin install is important for:
Extracting and inspecting the installer files
To get an idea of what is actually being installed and where
To ensure that the files look trustworthy and secure (no viruses - malware and viruses can still hide inside the MSI file though)
Deployment via systems management software (for example SCCM)
Corporate application repackaging
Repair, modify and self-repair operations
Patching & upgrades
MSI advertisement (among other details this involves the "run from source" feature where you can run directly from a network share and you only install shortcuts and registry data)
A number of other smaller details
Please read the stackoverflow post linked above for more details. It is quite an important concept for system administrators, application packagers, setup developers, release managers, and even the average user to see what they are installing etc...
Admin-install, practical how-to
You can perform an admin-install in a few different ways depending on how the installer is delivered. Essentially it is either delivered as an MSI file or wrapped in an setup.exe file.
Run these commands from an elevated command prompt, and follow the instructions in the GUI for the interactive command lines:
MSI files:
msiexec /a File.msi
that's to run with GUI, you can do it silently too:
msiexec /a File.msi TARGETDIR=C:\MyInstallPoint /qn
setup.exe files:
setup.exe /a
A setup.exe file can also be a legacy style setup (non-MSI) or the dreaded Installscript MSI file type - a well known buggy Installshield project type with hybrid non-standards-compliant MSI format. It is essentially an MSI with a custom, more advanced GUI, but it is also full of bugs.
For legacy setup.exe files the /a will do nothing, but you can try the /extract_all:[path] switch as explained in this pdf. It is a good reference for silent installation and other things as well. Another resource is this list of Installshield setup.exe command line parameters.
MSI patch files (*.MSP) can be applied to an admin image to properly extract its files. 7Zip will also be able to extract the files, but they will not be properly formatted.
Finally - the last resort - if no other way works, you can get hold of extracted setup files by cleaning out the temp folder on your system, launch the setup.exe interactively and then wait for the first dialog to show up. In most cases the installer will have extracted a bunch of files to a temp folder. Sometimes the files are plain, other times in CAB format, but Winzip, 7Zip or even Universal Extractor (haven't tested this product) - may be able to open these.
7-Zip should do the trick.
With it, you can extract all the files inside the EXE (thus, also an MSI file).
Although you can do it with 7-Zip, the better way is the administrative installation as pointed out by Stein Åsmul.
I'm guessing this question was mainly about InstallShield given the tags, but in case anyone comes here with the same problem for WiX-based packages (and possibly others), just call the installer with /extract, like so:
C:\> installer.exe /extract
That'll place the MSI in the folder alongside the installer.
Starting with parameter:
setup.exe /A
asks for saving included files (including MSI).
This may depend on the software which created the setup.exe.
The only way to do that is running the exe and collect the MSI. The thing you must take care of is that if you are tranforming the MSI using MST they might get lost.
I use this batch commandline:
SET TMP=c:\msipath
MD "%TMP%"
SET TEMP=%TMP%
start /d "c:\install" install.exe /L1033
PING 1.1.1.1 -n 1 -w 10000 >NUL
for /R "%TMP%" %%f in (*.msi) do copy "%%f" "%TMP%"
taskkill /F /IM msiexec.exe /T
Launch the installer, but don't press the Install > button. Then
cd "%AppData%\..\LocalLow\Sun\Java"
and find your MSI file in one of sub-directories (e.g., jre1.7.0_25).
Note that Data1.cab from that sub-directory will be required as well.
There is no need to use any tool !! We can follow the simple way.
I do not know which tool built your self-extracting Setup program and so, I will have to provide a general response.
Most programs of this nature extract the package file (.msi) into the TEMP directory. This behavior is the default behavior of InstallShield Developer.
Without additional information, I would recommend that you simply launch the setup and once the first MSI dialog is displayed, you can examine your TEMP directory for a newly created sub-directory or MSI file. Before cancelling/stopping an installer just copy that MSI file from TEMP folder. After that you can cancel the installation.

Windows Installer msi package

I have a windows installer msi package with the setup.exe bootstrap. Works fine everywhere.
However the client has supposedly uninstalled the application and then tried to run the setup.exe again and gets the following error in the log file: Launching Application. Error: Unable to locate application file 'xyz.msi'.
Now the setup.exe and the msi file are in the same folder. Is this even possible in any scenario?
I think it is looking somewhere daft for your MSI, probably in the MSI cache or System32.
I'd suggest using procmon to capture the file system searches and then search that output for your MSI file name. You'll see it is not found a few times but that will show you where it is looking.
Ryan
If you're looking for a quick, one-time fix you could also just try to run the .msi directly.

Resources