Installer created with Wix fails to be installed as system - wix

I have a quite simple installer created with Wix Toolset. My users complaints that they can't deploy this installer as system user. They have to do it as user. However, I have learned that installers can be deployed as system user. Could anyone tell me what I need to do in my wxs file so that they can deploy it as system user?

We typically deploy our MSIs using Microsoft SCCM as SYSTEM. We use PSEXEC to invoke a CMD prompt as SYSTEM to do our dev testing before sending it to SCCM. There are two reasons an installer would fail as SYSTEM:
1) User error: I can't tell you how many times I've seen packages put into SCCM with invalid command line arguments. One of my favorite is quotation marks get turned into Unicode quotation marks via email transmission. Another is logging to a directory that doesn't exist. Another is forgetting to tell the MSI to run silently. It just sits there and hangs. Another awesome one is typing the MSI name wrong. It's especially awesome because they almost give me an SCCM log when I ask for an MSI log. No MSI log means it's not the MSI's fault.
2) Installer design error: Have you tested your silent installs? Do you have any custom actions that make assumptions about the user context / environment? One of my old favorites (not) was InstallShield InstallScript custom actions that would fail due to a poorly designed DCOM interface for talking to the MSI session handle. It's been almost 10 years since that was fixed but I still come across installers now and then. Another example is assuming that the user will have rights to another machine or the internet (SYSTEM typically has neither in a corp environment.)
I'd start with testing as SYSTEM using PSEXEC. Log the install and see what the error is. Otherwise you haven't really given us any details to give a specific answer for.

You should get them to do a verbose log of what happens when they do the install. There are issues sometimes related to user specific locations, for example a file going to the user's personal folder, what does that mean for the system account? Or the install or a custom action may assume that a drive letter mapped for a user is system wide (they're not - they are per user) and that can cause errors. That's what Chris is saying too - the context matters. The system account does not have access to the interactive user's desktop, the network, profile locations that make no sense for a non-interactive account and so on.

I also am a SCCM user and regularly deploy apps through SCCM... This WIX installer also drived me crazy. But Christopher's reaction helped me...
1) If Wix installers get tested using PSexec, they probably work, SCCM, I don't know what it is, but installs keep failing without apparent reason. (but it fails installing as System is true)
Solution: incorporate psexec in your script in SCCM...
add your setup.exe & psexec.exe in your source folder. Use following syntax in your setup script:
copy psexec.exe to your software source location.
%~dp0PsExec.exe -accepteula \127.0.0.1 "%~dp0setup.exe" --quiet
2) #WIX dev team: also try to test with SCCM!
3) if above fails, you can also extend the suggestion with:
add following syntax in your setup script:
c:\windows\system32\net.exe user /add WixHelpInstaller PaSSW0rd
c:\windows\system32\net.exe localgroup administrators WixHelpInstaller /add
%~dp0PsExec.exe -accepteula -u .\WixHelpInstaller -p PaSSW0rd \\127.0.0.1 "%~dp0setup.exe" --quiet
c:\windows\system32\net.exe user WixHelpInstaller /delete

Related

MSI Installer revert the modified installation files if application starts with other user

I have a scenario,
On a particular machine, I am installing my custom software with MSI installer. MSI installer is created with PerMachine tag, so software is available for all the users of that machine.
Now,
I installed the software on C:\MyApp\ directory.
Then I modified a few configuration files present in C:\MyApp\Config folder to make sure the software connects with my other services.
I started the application, it's working fine.
Now, on the same machine, I logged in with another user.
I started the application.
MSI windows popup with some progress bar for installation.
It vanishes and the application starts but fails to load.
But all the files I have modified are reverted now, I need to again modify those.
Few points:
My installation direcotry is C:\MyApp, not any custom user directory. So modified files should be for all the users.
I think MSI is rolling back changes when I logged in with the new user.
How to stop this?
Please help
Self-Repair: Windows Installer self-repair is the cause of the behavior you see. See the link for an explanation of what happens. See more here - several links with information on self-repair from various angles.
Short Explanation: Essentially the launching of an advertised shortcut triggers an integrity check of the installed files and if a file or registry setting is found to be missing a self-repair ensues. It will put in place missing files and settings. During this process it will sometimes overwrite changed settings files - the problem you describe (due to various file overwrite oddities of Windows Installer - a long answer with various hints).
Fix?: My preferred fix for this is to not install the settings files and update them, but to rather have your application generate them on first launch - either one file per user or a shared one for all users. You can also use a read-only copy of the settings file that you install to copy to a new file that you generate and update. I also recommend you put these files in a writable location in the user profile and not in the main folder. Your setup will never interfere with these generated files. You can also try to set the hosting component for the files "permanent" and "never overwrite". Not very neat. Here is a whole rant on the subject. The very best solution - in my opinion - is to keep settings in databases and get them on launch. This allows good control of all settings. Look out for network and firewall issues.
I hope this answers your question. Are you installing IIS files? I find commercial tool Advanced Installer to have the better feature list for IIS installation - though I lack enough data to conclude. Some videos here: https://www.youtube.com/c/advancedinstaller/search?query=IIS - WiX is also very good, but without the nice GUI of Advanced Installer.
Note: you really should not install to the root of C:\ anything at all. Windows Installer actively tries to make it hard, and side-effects are likely. You can, however, target the IIS folders - wherever they are located.
Update: I found this old answer on how to allow selective update of settings files - I had to resurrect the linked forum answers from Wayback.

Uninstall is not working for MSI application - Error 1722

I have created MSI using WIX 3.11. I have made some customization to the Installer to install the application in a custom folder. I am also writing Install path to registry value under HKLM\Software.
I am reading registry value in batch file for one of my use-case.
Installation is successful and the application is running fine.
But while uninstalling, I am facing below issue -
Uninstall window pops up with the message - The following applications should be closed before continuing the Install: [MyApplication]
In uninstall log while removing the service, I see below error - Error 1722. 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.
If I remove the service manually, no errors can be seen and the service is getting deleted. Not sure why Uninstall is failing.
Please shed some light on this.
Stop Service Before Uninstall: In the compiled MSI, what entries do you have in the ServiceControl table? You need to stop the service before its executable is deleted. See WiX service installation sample linked to below.
Failing Custom Action: It is also possible that you have a custom action which tries to run a batch file that has already been uninstalled when you try to run it. This can be a custom action that should not run on uninstall (conditioning is wrong), or you have sequenced it incorrectly so the batch file is gone from disk - courtesy of the uninstall - before the custom action can run successfully. You need to move the custom action earlier in the installation / un-installation sequence or condition it better so it never runs on uninstall. Both issues are very common. Be aware that it is common to fail to condition custom actions so they run unexpectedly. Very often they run during major upgrade uninstalls undesirably.
Batch Files CAs: For what it is worth - and no offense: using batch files in custom action is an MSI anti-pattern in my opinion. There is basically zero error handling and hence no management and recovery from error conditions. And generally no MSI rollback support. C++ custom actions are best in my view (minimal dependencies, good debugability, full featured language, large down-to-the-metal API). Just so it is mentioned. It all depends how large your distribution is. For in-house appliations one can get away with more than for truly global package distribution. This has to do with the complexity of deployment (see section a bit down the page). There are so many error sources.
WiX Service Installation: Maybe see this hands on WiX-markup sample from Rainer Stropek: WiXSamples - github.com/rstropek. Please check
the ServiceControl element.
Common MSI Problems: I hate to "pitch" this content. It is essentially the things you can't easily find in books - and for good reason. Some rules of thumb and opinions in a chaotic form, but here it is if you want to check it out: How do I avoid common design flaws in my WiX / MSI deployment solution? Just honest opinions and practical advice - no claim to be "right", but it should help setup reliability. Hopefully.

Windows Installer-Avoid FileinUse dialog box when Installing a package

When ever there is an update patch of files that have to be replaced with the existing files and if one of the files is being used by any of the processes, then a file in use dialog box pops-up.I wanna avoid that dialog box and get that file queued up for installation so that it can be installed at the time of system reboot.
I have read that the queuing the files for update at the time of reboot is the inbuilt functionality of windows installer.
Can someone suggest me the way to remove that FileInUse Dialog box.
I tried setting up the "MsiRMFilesInUse" property to "0" but it didn't work.
"Short" Answer
Essentially: you could 1) run completely silently (suppresses the files-in-use dialog), 2) shut down locking
applications gracefully (application update to allow graceful shutdown - with or without restart manager support), 3) ensure proper service control (if dealing with services), 4) force-kill
running processes (the "sledgehammer-approach"), 5) abort setup if locks are detected, 6) require logoff before deployment, 7) install to a new folder for each version (side-by-side install), etc...
Below is a little drill-down of files-in-use issues and the Restart Manager - intended as a quick review for files-in-use and reboot issues.
In terms of your actual problem. I wouldn't mess with the FileInUse dialog(s). It won't really solve your problem. Maybe consider these pointers:
Services: If you are installing services and they trigger files-in-use issues, please see section on services towards the bottom to determine if you can improve your setup's logic.
Silent Mode: Running your setup in silent mode would be an obvious way to suppress such files-in-use dialogs, but then you have to suppress automatic reboot, or the system will spontaneously reboot without warning. Details below.
Policy: Please check if the DisableAutomaticApplicationShutdown policy is enabled on your box / standard PC configuration. See details below.
Registry location is: HKLM\Software\Policies\Microsoft\Windows\Installer.
I am not sure if enabling this policy will make the files-in-use dialogs disappear.
Restart Manager Compliance: Maybe check if you should update your application to heed the design of the Restart Manager feature - to allow for auto-magic and problem free upgrades by applications shutting themselves down gracefully (provided you are dealing with binaries that you can actually change yourself - in other words: you have the source code). Lots of details below.
"Setup Overkill": If you deem it safe to kill your application without mercy during upgrades, see section on this below.
Graceful Shutdown Custom Action: If you make your application capable of graceful shutdown (restart manager-style), then you can trigger such a shutdown yourself as well (easiest for user context processes) via an immediate mode custom action (in case Restart Manager is disabled by policy - look out for timing and timeout issues though - especially for silent running - "deadlock").
Side-By-Side Installation: some details below. Some companies decide to install applications truly side-by-side so there are no file overwrite issues with their new deployments (old versions uninstall may still trigger required reboots though).
I suppose you could also abort the install if locked files are detected, or you could require users to log off before the installation is run - if you have a distribution system.
Please at least skim the rest of the answer for more details and context.
Restart Manager
Your applications and services should be prepared to be shut down by the Restart Manager and save user data and state information that are needed for a clean restart. This requires updates and changes to the application / service to adhere to standards for shutdown and restart of the application.
The Restart Manager: is a new C-style API available beginning with Windows Vista and Windows Server 2008. Restart Manager consists of a single DLL that applications can load to access the Restart Manager API. The idea is that the Restart Manager will auto-magically shut down and restart your applications during installations / updates, by having the application / service follow a set of guidelines:
Guidelines for Applications - (the crucial tech-read)
Guidelines for Services
In essence: The whole idea is basically to prefer restarting applications rather than restarting the OS - and also to avoid reboots in general.. To that end: 1)
Your application calls RegisterApplicationRestart() with a command
line specified for its eventual restart - it "signs up" for restart
management. 2) Your application watches for WM_QUERYENDSESSION
messages and shuts down gracefully saving data in an appropriate way
when told to do so. 3) Then Restart Manager can restart the
application when finished installing (restart can be disabled).
More Technical stuff:
Here is a nice Symantec article on "Files In Use & The Restart Manager".
How do I add support for Windows Restart Manager to my application? (Advanced Installer)
Restart Manager Configuration: There are a number of properties that will affect how the Restart Manager will operate with Windows Installer:
MSIRESTARTMANAGERCONTROL - use the Restart Manager or FileInUse Dialog
MSIDISABLERMRESTART - restart or don't restart shut down applications
MSIRMSHUTDOWN - shutdown, force shutdown or do not force shutdown
When Restart Manager is used, the MsiRMFilesInUse dialog is used instead of the FileInUse dialog to show a list of applications that have locked files.
N.B! The whole Restart Manager feature can also be disabled by policy:
DisableAutomaticApplicationShutdown policy.
Check in HKLM\Software\Policies\Microsoft\Windows\Installer.
Restart Manager behavior with Windows installer
FileInUse
If you don't have the time or resources to implement proper interoperability with the Restart Manager (which is frankly the only sane thing to spend your resources on at this point in Windows's development), then there are a few things that might be good to know:
Silent Install: The first obvious thing to point out is that there will be no FileInUse dialog if you install the setup in silent mode. However, this could trigger a system reboot unless you specify the REBOOT=ReallySuppress property.
Services: Do you install services that you do not properly shut down during upgrade? There are built-in MSI constructs to shut down services during upgrades - the Service Control table.
Used properly, this ServiceControl feature means you no longer have any problems with service executables triggering a reboot to be replaced (barring shutdown problems in the service itself).
This is a built-in MSI constructs and works well when used right. People should not resort to custom actions to install services.
Application Support: Beyond interoperability with the Restart Manager, some application - that have files in use - can shut down gracefully when told to do so.
Some applications shut down properly when sent a command line, for example App.exe -shutdown, despite not having been written to be interoperable with the Restart Manager. Maybe system tray applications that save no data for the user?
This obviously has to be implemented specifically for the application in question - and if you do that, you should use the Restart Manager instead at this point (or additionally, you could have both call the same actual shutdown implementation).
"Setup Overkill": some setups are designed to just kill application processes that are open at the time of installation.
Not ideal, but it can work for certain types of applications that run in the background (OK, it is nuts, but it is done regularly).
Use a custom action or whatever built-in constructs are available in your deployment tool.
WiX: Kill windows service forcefully in WIX. WiX: CloseApplication.
VBScript: Close an application using VBScript.
Advanced Installer: How to detect or stop a process.
Installshield: Kill process. Kill process documentation.
REINSTALLMODE: Do you perhaps use REINSTALLMODE="amus" to force overwrite files during installation?
This can dramatically increase the amount of files in-use and reboot prompts since all files are attempted replaced - and generally unnecessarily so - especially in repair and modify scenarios.
This is particularly true for setups that install services that do not use the ServiceControl table properly to shut down the service before trying to overwrite its binary.
Side-By-Side Installations (SO): adding this for reference, it is beyond the scope of what is "normally relevant". This approach requires quite a bit of technical changes and proper distribution processes to be successful - it is primarily for in-house, core corporate applications (full app control possible) - in my opinion.
New versions, targeting new installation folders (add version number to installation folder?), can generally install without any file overwrite issues (unless any system-shared files are updated - in which case you should split them to a separate pre-requisite MSI - with its own distribution logic - when required - which should be rarely).
Older version uninstall can still trigger reboot requirements as the files can be in-use and not ready to be uninstalled. Obviously.
You can use automatic GUIDs for the setup components - so MSI can keep them tracked separately in a correct fashion. You must generally eliminate all need to set static components (or they must be installed to shared locations and kept static - or updated via a separate pre-requisite MSI when required).
The whole application must be "well behaved" for side-by-side use and installation. In other words not fight over file associations and load all resources properly and manage database connections that could be shared between instances, etc...
You add the version number to the start menu shortcut? Somehow you must be able to differentiate installations and launch the desired version - obviously. The application should be aware of its doppelgängers?
I might consider setting a new upgrade code for each release, in order to decouple the products from one another, and then use the distribution system to uninstall older, legacy versions (as a weekend or monthly batch job?). This is not 100% necessary, it all depends on your scenario. Lots of things can work when planned coherently - obviously.
Applications not suitable for normal side-by-side operation may sometimes be virtualized and sandboxed using App-V (virtual packages) to allow different versions to co-exist on the same box. New challenges.
Some Further Links:
FileInUse or FilesInUse (lots of inside information from a Symantec employee towards bottom)
Terminating process in CustomAction
Restart Manager behavior with Windows installer
How can I stop an .exe on repair, update and delete in wix?
RmGetList() API fails when file is locked using Ez file locker but works with another file locking utility
Suppress an MSI error code
Wix stop service on uninstall/upgrade: prevent "restart popup" (file-in-use situation)
Assuming you are the package author, I would suggest following the norms, which are to use the MsiRMFilesInUse dialog. But if you want to attempt to disable things anyway, start by understanding the guidance for package authors on Using Windows Installer with Restart Manager:
Add the MsiRMFilesInUse dialog box to your package. If the MsiRMFilesInUse dialog box is present in the package, the Windows Vista user running an installation at the Full UI user interface level is given the option to automatically close and restart applications. An installation package can contain information for both the MsiRMFilesInUse dialog box and the FilesInUse dialog box. The MsiRMFilesInUse dialog box is only displayed if the package is installed with at least Windows Installer 4.0 on Windows Vista, and is otherwise ignored. Existing packages that do not have the MsiRMFilesInUse dialog box continue to function using the FilesInUse dialog box. A customization transform can be used to add an MsiRMFilesInUse dialog box to existing packages.
End-users typically run installations at the Full UI user interface level. Basic UI or Reduced UI level installations give the user the option of using the Restart Manager to reduce system restarts even if the MsiRMFilesInUse dialog box is not present. Silent UI level installations always shut down applications and services, and on Windows Vista, always use Restart Manager.
: : :
Package authors can base a condition in the LaunchCondition table on the MsiSystemRebootPending property to prevent the installation of their package when a system restart is pending.
Package authors and administrators can control the interaction of the Windows Installer and Restart Manager by using the MSIRESTARTMANAGERCONTROL, MSIDISABLERMRESTART, MSIRMSHUTDOWN properties and the DisableAutomaticApplicationShutdown policy.
Setting MSIRESTARTMANAGERCONTROL=Disable, possibly removing the FilesInUse and MsiRMFilesInUse dialogs from your package, and optionally tweaking further settings discussed on System Reboots (such as setting the REBOOT or REBOOTPROMPT properties) may have the effect you desire.
If you are not the package author, you are probably asking in the wrong forum. The
DisableAutomaticApplicationShutdown policy sounds like it could do most of what you describe, and would apply to all packages installed on your machine. It is intended for use by systems administrators instead of package authors. Alternately you could create transforms (or specify properties on the installation command line) to effectively alter the package like the package author would have.
Hopefully not repeating too much here, but I'll start by pointing out that the reason for that dialog is to avoid reboots. You didn't say why you want to wait for a reboot instead of using the in-use functionality that lets you avoid rebooting in the first place. It's also unclear about when your next reboot is expected, the issue being that the install of the app is not complete until all the files have been completely replaced and updated. It's not unusual for an incompletely installed app to crash because its current state is some set of old and new files mixed together.
There is no MsiRMFilesInUse property, so setting it has no effect.
The MSIRESTARTMANAGERCONTROL property tells Windows whether to use the older FilesInUse behavior or the new Restart Manager FilesInUse methods of in-use detection. It does not turn off files-in-use behavior detection, it's just a switch between old and new methods. Because the detection methods differ you may see different behavior depending on what files are actually in use (only apps with open windows are detected by the old methods).
You should say which tool you are using to build your MSI file because they have different capabilities. Visual Studio setups have virtually no support for automatic shutdown, except that if you are installing services with installer classes then your Uninstall method could be extended to stop the service at uninstall time. If you are using WiX then there are util::CloseApplication capabilities.
The supported Windows shutdown method is to integrate your apps with Restart Manager, and Stein has links. For services, the "normal" service install with MSI ServiceInstall/ServiceControl takes care of this, but not for Visual Studio setup projects with installer classes.
Finally, create an MSI verbose log and look for in use entries, usually with a 1603 error (the file in use flavor, not the install crashed flavor). You may not need this log if the dialogs tell you the apps that need shutting down, so just focus on a way to get them stopped on an update, because that's a better solution rather than attempting to suppress the default Windows behavior.

Installing multiple instances of an Application with Wix Toolset

I simply need to install multiple instances of my application saving them in different folders, with no shortcut on desktop.
In other words, when the App is already installed in a Folder, if I double-click the .msi file once again, the installer shouldn’t ask me if I want repair or remove my App, but it simply should permit to install it in a new folder.
How can I solve this problem?
I used to work with this kind of installations before, and I would agree with #Nikolay - it is rather an exception, than the rule when it comes to Windows Installer based installations. Component rules are often tricky to follow, and multiple instances aspect adds some complexity on top. So, think twice before you go this road.
Being complex, it is still possible. Years ago I published the article of how to start authoring multiple instance installations with WiX 3.6. Note that this version of WiX simplifies it significantly. It's not a short read, so here is a quick digest:
You won't be able to achieve the "install each new instance with double-clicking MSI file" behavior. You have to have a bootstrapper - something that passes correct command line parameters to msiexec.exe.
Don't try to support unlimited number of instances - try sticking with reasonably big number. Do you imagine someone installing your app 10 times on a machine? 50? 100? Make a sane choice - this will be the number of your <Instance/> elements.
Although you only have to decorate non-file data components with MultiInstance attribute, I don't think it will break if you add it to all of your components.
Although I explained the patching of multiple instances in that post, I would only use it in production if I had no other choice.
What you are asking for is not normal in Windows. Normally, each program (product) is installed only once. I.e. each installation package has it's ID (called "ProductID"). If that ID already registered in the system as installed, the system will not allow you to install the second product with the same ProductID, but start change/remove.
What you can do:
Don't use Windows Installer (and WIX), use ZIP for example, or some self-extracting archive, or some other program which does not register installed product in the system.
Use command line to change product id before installing if you want MSI and Windows Installer for whatever reason. Try googling on "use transforms to install the same MSI multiple times". Thus you can have the same MSI per-transformed before installation, so that it looks as a different one to the system.
Install per-user, if that's good enough for you (i.e. don't install to Program Files, install to user folder)
Maybe there are other options...

Adding software setup to installer

I'm writing an installer for an application. Most of the installer is done and working, but I have on more step outstanding. I need some way to add a setup window to the installer, that will take user input like server address and port, etc. and write these to the relevant files for system start-up. This preferably done through a GUI of sorts inside the installer.
I've tried creating an executable file that runs after installation, but this does not always execute on different systems.
Is there a way to add a GUI to the installer itself that executes after the directory structures and files have been put into place?
Thanks in advance.
In general you should seriously consider doing this as a standalone app that runs when the app first runs and needs configuring. Then it's a program that runs in a user context and can be tested and debugged in the normal way. At least consider what the user is going to do if they want to change the server address or the port - will they need to uninstall your app and reinstall it just to change the server details or the port?
The GUI may not run correctly when started from the install for a number of reasons. It may be initiated with the system account if it's a deferred CA. It wasn't started from the interactive user shell, so it probably won't have any idea of a working directory. It's being run from an msiexec.exe process running in the system directory and maybe with a system account - that's not really the place to be doing your GUI configuration.
I assume you're using WiX, it doesn't say so in your question but it's tagged with WiX.
I would have a read of http://wix.tramontana.co.hu/tutorial/user-interface-revisited (or http://www.dizzymonkeydesign.com/blog/misc/adding-and-customizing-dlgs-in-wix-3/ has a relatively easy to read example), you can add or edit any of the dialogue boxes in the installer, you'll need to download the source to get at the built in dialog, and it does require some "play" to get everything quite right but worth it to get a professional looking installer.